From 8eb8eb751e580aa8b41e348d4fba9bd66fe9fee0 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Thu, 17 Sep 2015 22:19:26 +0900 Subject: [PATCH] add tests for reading binary array --- irteus/demo/sample-camera-model.l | 4 ++-- irteus/irtsensor.l | 4 ++-- irteus/test/binary-reader.l | 40 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 irteus/test/binary-reader.l diff --git a/irteus/demo/sample-camera-model.l b/irteus/demo/sample-camera-model.l index 859056def..446f5c4bd 100644 --- a/irteus/demo/sample-camera-model.l +++ b/irteus/demo/sample-camera-model.l @@ -1,8 +1,8 @@ ;; create camera and camera viewer (setq *camera-model* - (make-camera-from-param :pwidth 640 :pheight 360 + (make-camera-from-param :pwidth 640 :pheight 640 :fx 400 :fy 400 - :cx 319.5 :cy 179.5 :name "camtest" + :cx 319.5 :cy 319.5 :name "camtest" :create-viewer t)) ;; move camera (send *camera-model* :translate #f(0 100 0) :world) diff --git a/irteus/irtsensor.l b/irteus/irtsensor.l index e7cbda45d..555ce1cac 100644 --- a/irteus/irtsensor.l +++ b/irteus/irtsensor.l @@ -220,7 +220,6 @@ ;; glview define view-directoin to oppsite direction (setq viewtarget (v- viewpoint (send self :viewing :view-direction) )) - (pprint (list viewpoint viewtarget (v- (send self :viewing :view-up)))) (gl::gluLookAtfv (concatenate vector viewpoint viewtarget (v- (send self :viewing :view-up)))) (gl::glMatrixMode gl::GL_MODELVIEW) @@ -228,7 +227,8 @@ (send vwr :viewsurface :clear) (setq pcolor (send vwr :viewsurface :color)) (send vwr :viewsurface :color pcolor) - + (gl::glEnable gl::GL_LIGHTING) + (gl::glDisable gl::GL_BLEND) (dolist (abody draw-things) ;; draw body (cond diff --git a/irteus/test/binary-reader.l b/irteus/test/binary-reader.l new file mode 100644 index 000000000..fb6fcec31 --- /dev/null +++ b/irteus/test/binary-reader.l @@ -0,0 +1,40 @@ +(require :unittest "lib/llib/unittest.l") + +(init-unit-test) + +(deftest binary-reader + (let (sv iv lv fv f32v dv) + ;; integer + (setq sv #g((4) :short "CgBkAOgDECc=")) + (assert (v= sv #i(10 100 1000 10000))) + (setq iv #g((4) :integer "FAAAAMgAAADQBwAAIE4AAA==" )) + (assert (v= iv #i(20 200 2000 20000))) + (setq lv #g((4) :long "HgAAAAAAAAAsAQAAAAAAALgLAAAAAAAAMHUAAAAAAAA=")) + (assert (v= lv #i(30 300 3000 30000))) + ;; float + (setq fv #g((4) :float "bxKDOgrXIzzNzMw9AACAPw==")) + (assert (eps-v= fv #f(0.001 0.01 0.1 1.0))) + (setq f32v #g((4) :float "bxKDOgrXIzzNzMw9AACAPw==")) + (assert (eps-v= f32v #f(0.001 0.01 0.1 1.0))) + (setq dv #g((4) :double "/Knx0k1iYD97FK5H4XqUP5qZmZmZmck/MzMzMzMz8z8=")) + (assert (eps-v= dv #f(0.002 0.02 0.2 1.2))) + ) + (let (im fm fmm) + (setq im #g((3 3) :integer "CgAAABQAAAAeAAAAZAAAAMgAAAAsAQAA6AMAANAHAAC4CwAA")) + (assert (equal (array-dimensions im) (list 3 3))) + (assert + (v= (array-entity im) #i(10 20 30 100 200 300 1000 2000 3000))) + (setq fm #g((3 3) :float "bxKDOm8SAzumm0Q7CtcjPArXozyPwvU8zczMPc3MTD6amZk+")) + (assert (equal (array-dimensions fm) (list 3 3))) + (assert + (eps-v= (array-entity fm) #f(0.001 0.002 0.003 0.01 0.02 0.03 0.1 0.2 0.3))) + (setq fmm #g((2 2 2) :float "bxKDOm8SAzsK1yM8CtejPM3MzD3NzEw+zcyMP5qZmT8=")) + (assert (equal (array-dimensions fmm) (list 2 2 2))) + (assert + (eps-v= (array-entity fmm) #f(0.001 0.002 0.01 0.02 0.1 0.2 1.1 1.2))) + ) + ;;(setq note #g((4) :notexistingtype "")) ;; error + ) + +(run-all-tests) +(exit)