From bc1f8f7a8218ee028002194e7e5f627b17f7d77e 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/test/binary-reader.l | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 irteus/test/binary-reader.l diff --git a/irteus/test/binary-reader.l b/irteus/test/binary-reader.l new file mode 100644 index 000000000..edac0370f --- /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 " ")) + (assert (v= sv #i(8224 8224 8224 8224))) + (setq iv #g((4) :integer " ")) + (assert (v= iv #i(538976288 538976288 538976288 538976288))) + (setq lv #g((4) :long " ")) + (assert (v= lv #i(2314885530818453536 2314885530818453536 2314885530818453536 2314885530818453536))) + ;; float + (setq fv #g((4) :float " A a Z")) + (assert (v= fv #f(1.00078430175781250000e+01 1.84612118875124793344e+20 1.35631564269401118307e-19 1.12678295211868160000e+16))) + (setq f32v #g((4) :float32 " A a Z")) + (assert (v= f32v #f(1.00078430175781250000e+01 1.84612118875124793344e+20 1.35631564269401118307e-19 1.12678295211868160000e+16))) + (setq dv #g((2) :double " A a Z")) + (assert (v= dv #f(7.08468741563101165134e+159 1.36446099760464422337e+126))) + ) + (let (im fm fmm) + (setq im #g((3 3) :integer " ")) + (assert (equal (array-dimensions im) (list 3 3))) + (assert + (v= (array-entity im) #i(538976288 538976288 538976288 538976288 538976288 538976288 538976288 538976288 538976288))) + (setq fm #g((3 3) :float " . . . , , , [ [ [")) + (assert (equal (array-dimensions fm) (list 3 3))) + (assert + (v= (array-entity fm) #f(3.64083208026499960397e-11 3.64083208026499960397e-11 3.64083208026499960397e-11 2.27552005016562475248e-12 2.27552005016562475248e-12 2.27552005016562475248e-12 4.50713180847472640000e+16 4.50713180847472640000e+16 4.50713180847472640000e+16))) + (setq fmm #g((2 2 2) :float " < < > > ( ( ) )")) + (assert (equal (array-dimensions fmm) (list 2 2 2))) + (assert + (v= (array-entity fmm) #f(9.77328419685363769531e-03 9.77328419685363769531e-03 1.56372547149658203125e-01 1.56372547149658203125e-01 8.88875019595947168938e-15 8.88875019595947168938e-15 3.55550007838378867575e-14 3.55550007838378867575e-14))) + ) + ;;(setq note #g((4) :notexistingtype "")) ;; error + ) + +(run-all-tests) +(exit)