Skip to content

Commit

Permalink
FEAT: added "bincode" tests for recently added key-words (STRING and …
Browse files Browse the repository at this point in the history
…UNIXTIME-NOW-LE)
  • Loading branch information
Oldes committed Nov 16, 2018
1 parent 140a5d7 commit 1c5924f
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/tests/units/bincode-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,17 @@ is-protected-error?: func[code][
--test-- "BinCode - UNIXTIME-NOW"
;Writes UNIX time as UI32 value
b: binary 4
binary/write b [UNIXTIME-NOW]
--assert 4 = length? b/buffer
binary/read b [i: UI32]
binary/write b [UNIXTIME-NOW UNIXTIME-NOW-LE]
--assert 8 = length? b/buffer
binary/read b [t1: UI32 t2: UI32LE]
time: now/utc
--assert time/date = (1-Jan-1970 + (to integer! i / 86400))
--assert time/hour = (to-integer i // 86400 / 3600)
--assert time/minute = (to-integer i // 86400 // 3600 / 60)
--assert time/date = (1-Jan-1970 + (to integer! t1 / 86400))
--assert time/hour = (to-integer t1 // 86400 / 3600)
--assert time/minute = (to-integer t1 // 86400 // 3600 / 60)
;lets say that seconds will be ok too:)
--assert time/date = (1-Jan-1970 + (to integer! t2 / 86400))
--assert time/hour = (to-integer t2 // 86400 / 3600)
--assert time/minute = (to-integer t2 // 86400 // 3600 / 60)

--test-- "BinCode - overwrite protected values"
out: copy #{} ;not yet protected
Expand All @@ -211,8 +214,12 @@ is-protected-error?: func[code][
--assert is-protected-error? [binary/read/into out [at 1 ui8] blk]
unprotect/words [blk out i]



--test-- "BinCode - STRING"
;@@ this is yet not fully implemented feature! So far only reading.
b: binary #{74657374002A}
binary/read b [str: STRING i: UI8]
--assert str = "test"
--assert i = 42

===end-group===

Expand Down

0 comments on commit 1c5924f

Please sign in to comment.