-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49ff867
commit bc1f8f7
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |