Skip to content

Commit

Permalink
test: add big/little endian 32 bit tests
Browse files Browse the repository at this point in the history
Test that the exported lisp functions behave as expected
when writing and reading big and little endian 32 bit values
to and from lone lisp bytes objects.
  • Loading branch information
matheusmoreira committed Sep 11, 2024
1 parent 4cc31f2 commit 0194c20
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
36 changes: 34 additions & 2 deletions test/lone/lisp/modules/intrinsic/bytes/write-then-read/32/input
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
(math /)
(bytes
new
read-u32 write-u32
read-s32 write-s32))
read-u32 write-u32
read-s32 write-s32
read-u32le write-u32le
read-s32le write-s32le
read-u32be write-u32be
read-s32be write-s32be))

(set max-bits 32)
(set memory (new (/ max-bits 8)))
Expand All @@ -16,3 +20,31 @@
(print (write-s32 memory 0 -2000000000))
(print (read-u32 memory 0))
(print (read-s32 memory 0))

(print (write-u32le memory 0 +4000000000))
(print memory)
(print (read-u32le memory 0))
(print (read-s32le memory 0))
(print (read-u32be memory 0))
(print (read-s32be memory 0))

(print (write-s32le memory 0 -2000000000))
(print memory)
(print (read-u32le memory 0))
(print (read-s32le memory 0))
(print (read-u32be memory 0))
(print (read-s32be memory 0))

(print (write-u32be memory 0 +4000000000))
(print memory)
(print (read-u32le memory 0))
(print (read-s32le memory 0))
(print (read-u32be memory 0))
(print (read-s32be memory 0))

(print (write-s32be memory 0 -2000000000))
(print memory)
(print (read-u32le memory 0))
(print (read-s32le memory 0))
(print (read-u32be memory 0))
(print (read-s32be memory 0))
24 changes: 24 additions & 0 deletions test/lone/lisp/modules/intrinsic/bytes/write-then-read/32/output
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,27 @@
-2000000000
2294967296
-2000000000
4000000000
bytes[0x00286BEE]
4000000000
-294967296
2649070
2649070
-2000000000
bytes[0x006CCA88]
2294967296
-2000000000
7129736
7129736
4000000000
bytes[0xEE6B2800]
2649070
2649070
4000000000
-294967296
-2000000000
bytes[0x88CA6C00]
7129736
7129736
2294967296
-2000000000

0 comments on commit 0194c20

Please sign in to comment.