|
|
|
@ -27,15 +27,15 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(let ([stream (+DecodeStream (bytes #xab #xff))])
|
|
|
|
|
(check-equal? (send uint8 decode stream) #xab)
|
|
|
|
|
(check-equal? (send uint8 decode stream) #xff))
|
|
|
|
|
(check-equal? (decode uint8 stream) #xab)
|
|
|
|
|
(check-equal? (decode uint8 stream) #xff))
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint8 size) 1)
|
|
|
|
|
(check-equal? (size uint8) 1)
|
|
|
|
|
|
|
|
|
|
(let ([stream (+EncodeStream)])
|
|
|
|
|
(send uint8 encode stream #xab)
|
|
|
|
|
(send uint8 encode stream #xff)
|
|
|
|
|
(check-equal? (send stream dump) (bytes #xab #xff)))
|
|
|
|
|
(encode uint8 stream #xab)
|
|
|
|
|
(encode uint8 stream #xff)
|
|
|
|
|
(check-equal? (dump stream) (bytes #xab #xff)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
@ -44,7 +44,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint16.should.equal uint16be
|
|
|
|
|
|
|
|
|
|
;; modified test: `uint16` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send uint16 decode (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode uint16 (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
uint16be
|
|
|
|
|
uint16le) decode (bytes 0 1)))
|
|
|
|
|
|
|
|
|
@ -66,9 +66,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint16be.encode(stream, 0xabff)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint16be decode (+DecodeStream (bytes #xab #xff))) #xabff)
|
|
|
|
|
(check-equal? (send uint16be size) 2)
|
|
|
|
|
(check-equal? (send uint16be encode #f #xabff) (bytes #xab #xff))
|
|
|
|
|
(check-equal? (decode uint16be (+DecodeStream (bytes #xab #xff))) #xabff)
|
|
|
|
|
(check-equal? (size uint16be) 2)
|
|
|
|
|
(check-equal? (encode uint16be #f #xabff) (bytes #xab #xff))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'uint16le', ->
|
|
|
|
@ -88,9 +88,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint16le.encode(stream, 0xabff)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint16le decode (+DecodeStream (bytes #xff #xab))) #xabff)
|
|
|
|
|
(check-equal? (send uint16le size) 2)
|
|
|
|
|
(check-equal? (send uint16le encode #f #xabff) (bytes #xff #xab))
|
|
|
|
|
(check-equal? (decode uint16le (+DecodeStream (bytes #xff #xab))) #xabff)
|
|
|
|
|
(check-equal? (size uint16le) 2)
|
|
|
|
|
(check-equal? (encode uint16le #f #xabff) (bytes #xff #xab))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'uint24', ->
|
|
|
|
@ -98,7 +98,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint24.should.equal uint24be
|
|
|
|
|
|
|
|
|
|
;; modified test: `uint24` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send uint24 decode (bytes 0 1 2)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode uint24 (bytes 0 1 2)) (send (if (system-big-endian?)
|
|
|
|
|
uint24be
|
|
|
|
|
uint24le) decode (bytes 0 1 2)))
|
|
|
|
|
|
|
|
|
@ -120,9 +120,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint24be.encode(stream, 0xffab24)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint24be decode (+DecodeStream (bytes #xff #xab #x24))) #xffab24)
|
|
|
|
|
(check-equal? (send uint24be size) 3)
|
|
|
|
|
(check-equal? (send uint24be encode #f #xffab24) (bytes #xff #xab #x24))
|
|
|
|
|
(check-equal? (decode uint24be (+DecodeStream (bytes #xff #xab #x24))) #xffab24)
|
|
|
|
|
(check-equal? (size uint24be) 3)
|
|
|
|
|
(check-equal? (encode uint24be #f #xffab24) (bytes #xff #xab #x24))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'uint24le', ->
|
|
|
|
@ -142,9 +142,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint24le.encode(stream, 0xffab24)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint24le decode (+DecodeStream (bytes #x24 #xab #xff))) #xffab24)
|
|
|
|
|
(check-equal? (send uint24le size) 3)
|
|
|
|
|
(check-equal? (send uint24le encode #f #xffab24) (bytes #x24 #xab #xff))
|
|
|
|
|
(check-equal? (decode uint24le (+DecodeStream (bytes #x24 #xab #xff))) #xffab24)
|
|
|
|
|
(check-equal? (size uint24le) 3)
|
|
|
|
|
(check-equal? (encode uint24le #f #xffab24) (bytes #x24 #xab #xff))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'uint32', ->
|
|
|
|
@ -152,7 +152,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint32.should.equal uint32be
|
|
|
|
|
|
|
|
|
|
;; modified test: `uint32` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send uint32 decode (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode uint32 (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
uint32be
|
|
|
|
|
uint32le) decode (bytes 0 1 2 3)))
|
|
|
|
|
|
|
|
|
@ -174,9 +174,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint32be.encode(stream, 0xffab24bf)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint32be decode (+DecodeStream (bytes #xff #xab #x24 #xbf))) #xffab24bf)
|
|
|
|
|
(check-equal? (send uint32be size) 4)
|
|
|
|
|
(check-equal? (send uint32be encode #f #xffab24bf) (bytes #xff #xab #x24 #xbf))
|
|
|
|
|
(check-equal? (decode uint32be (+DecodeStream (bytes #xff #xab #x24 #xbf))) #xffab24bf)
|
|
|
|
|
(check-equal? (size uint32be) 4)
|
|
|
|
|
(check-equal? (encode uint32be #f #xffab24bf) (bytes #xff #xab #x24 #xbf))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'uint32le', ->
|
|
|
|
@ -196,9 +196,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; uint32le.encode(stream, 0xffab24bf)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send uint32le decode (+DecodeStream (bytes #xbf #x24 #xab #xff))) #xffab24bf)
|
|
|
|
|
(check-equal? (send uint32le size) 4)
|
|
|
|
|
(check-equal? (send uint32le encode #f #xffab24bf) (bytes #xbf #x24 #xab #xff))
|
|
|
|
|
(check-equal? (decode uint32le (+DecodeStream (bytes #xbf #x24 #xab #xff))) #xffab24bf)
|
|
|
|
|
(check-equal? (size uint32le) 4)
|
|
|
|
|
(check-equal? (encode uint32le #f #xffab24bf) (bytes #xbf #x24 #xab #xff))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
@ -222,15 +222,15 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(let ([stream (+DecodeStream (bytes #x7f #xff))])
|
|
|
|
|
(check-equal? (send int8 decode stream) 127)
|
|
|
|
|
(check-equal? (send int8 decode stream) -1))
|
|
|
|
|
(check-equal? (decode int8 stream) 127)
|
|
|
|
|
(check-equal? (decode int8 stream) -1))
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int8 size) 1)
|
|
|
|
|
(check-equal? (size int8) 1)
|
|
|
|
|
|
|
|
|
|
(let ([stream (+EncodeStream)])
|
|
|
|
|
(send int8 encode stream 127)
|
|
|
|
|
(send int8 encode stream -1)
|
|
|
|
|
(check-equal? (send stream dump) (bytes #x7f #xff)))
|
|
|
|
|
(encode int8 stream 127)
|
|
|
|
|
(encode int8 stream -1)
|
|
|
|
|
(check-equal? (dump stream) (bytes #x7f #xff)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
@ -239,7 +239,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int16.should.equal int16be
|
|
|
|
|
|
|
|
|
|
;; modified test: `int16` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send int16 decode (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode int16 (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
int16be
|
|
|
|
|
int16le) decode (bytes 0 1)))
|
|
|
|
|
|
|
|
|
@ -263,13 +263,13 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(let ([stream (+DecodeStream (bytes #xff #xab))])
|
|
|
|
|
(check-equal? (send int16be decode stream) -85))
|
|
|
|
|
(check-equal? (decode int16be stream) -85))
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int16be size) 2)
|
|
|
|
|
(check-equal? (size int16be) 2)
|
|
|
|
|
|
|
|
|
|
(let ([stream (+EncodeStream)])
|
|
|
|
|
(send int16be encode stream -85)
|
|
|
|
|
(check-equal? (send stream dump) (bytes #xff #xab)))
|
|
|
|
|
(encode int16be stream -85)
|
|
|
|
|
(check-equal? (dump stream) (bytes #xff #xab)))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'int16le', ->
|
|
|
|
@ -290,9 +290,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int16le decode (+DecodeStream (bytes #xab #xff))) -85)
|
|
|
|
|
(check-equal? (send int16le size) 2)
|
|
|
|
|
(check-equal? (send int16le encode #f -85) (bytes #xab #xff))
|
|
|
|
|
(check-equal? (decode int16le (+DecodeStream (bytes #xab #xff))) -85)
|
|
|
|
|
(check-equal? (size int16le) 2)
|
|
|
|
|
(check-equal? (encode int16le #f -85) (bytes #xab #xff))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
@ -301,7 +301,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int24.should.equal int24be
|
|
|
|
|
|
|
|
|
|
;; modified test: `int24` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send int24 decode (bytes 0 1 2)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode int24 (bytes 0 1 2)) (send (if (system-big-endian?)
|
|
|
|
|
int24be
|
|
|
|
|
int24le) decode (bytes 0 1 2)))
|
|
|
|
|
|
|
|
|
@ -324,9 +324,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int24be.encode(stream, -21724)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int24be decode (+DecodeStream (bytes #xff #xab #x24))) -21724)
|
|
|
|
|
(check-equal? (send int24be size) 3)
|
|
|
|
|
(check-equal? (send int24be encode #f -21724) (bytes #xff #xab #x24))
|
|
|
|
|
(check-equal? (decode int24be (+DecodeStream (bytes #xff #xab #x24))) -21724)
|
|
|
|
|
(check-equal? (size int24be) 3)
|
|
|
|
|
(check-equal? (encode int24be #f -21724) (bytes #xff #xab #x24))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'int24le', ->
|
|
|
|
@ -347,9 +347,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int24le decode (+DecodeStream (bytes #x24 #xab #xff))) -21724)
|
|
|
|
|
(check-equal? (send int24le size) 3)
|
|
|
|
|
(check-equal? (send int24le encode #f -21724) (bytes #x24 #xab #xff))
|
|
|
|
|
(check-equal? (decode int24le (+DecodeStream (bytes #x24 #xab #xff))) -21724)
|
|
|
|
|
(check-equal? (size int24le) 3)
|
|
|
|
|
(check-equal? (encode int24le #f -21724) (bytes #x24 #xab #xff))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -358,7 +358,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int32.should.equal int32be
|
|
|
|
|
|
|
|
|
|
;; modified test: `int32` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send int32 decode (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode int32 (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
int32be
|
|
|
|
|
int32le) decode (bytes 0 1 2 3)))
|
|
|
|
|
|
|
|
|
@ -382,9 +382,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int32be.encode(stream, -5561153)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int32be decode (+DecodeStream (bytes #xff #xab #x24 #xbf))) -5561153)
|
|
|
|
|
(check-equal? (send int32be size) 4)
|
|
|
|
|
(check-equal? (send int32be encode #f -5561153) (bytes #xff #xab #x24 #xbf))
|
|
|
|
|
(check-equal? (decode int32be (+DecodeStream (bytes #xff #xab #x24 #xbf))) -5561153)
|
|
|
|
|
(check-equal? (size int32be) 4)
|
|
|
|
|
(check-equal? (encode int32be #f -5561153) (bytes #xff #xab #x24 #xbf))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'int32le', ->
|
|
|
|
@ -404,9 +404,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; int32le.encode(stream, -5561153)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send int32le decode (+DecodeStream (bytes #xbf #x24 #xab #xff))) -5561153)
|
|
|
|
|
(check-equal? (send int32le size) 4)
|
|
|
|
|
(check-equal? (send int32le encode #f -5561153) (bytes #xbf #x24 #xab #xff))
|
|
|
|
|
(check-equal? (decode int32le (+DecodeStream (bytes #xbf #x24 #xab #xff))) -5561153)
|
|
|
|
|
(check-equal? (size int32le) 4)
|
|
|
|
|
(check-equal? (encode int32le #f -5561153) (bytes #xbf #x24 #xab #xff))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'float', ->
|
|
|
|
@ -414,7 +414,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; float.should.equal floatbe
|
|
|
|
|
|
|
|
|
|
;; modified test: `float` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send float decode (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode float (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
floatbe
|
|
|
|
|
floatle) decode (bytes 0 1 2 3)))
|
|
|
|
|
|
|
|
|
@ -436,9 +436,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; floatbe.encode(stream, 250.55)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-= (send floatbe decode (+DecodeStream (bytes #x43 #x7a #x8c #xcd))) 250.55 0.01)
|
|
|
|
|
(check-equal? (send floatbe size) 4)
|
|
|
|
|
(check-equal? (send floatbe encode #f 250.55) (bytes #x43 #x7a #x8c #xcd))
|
|
|
|
|
(check-= (decode floatbe (+DecodeStream (bytes #x43 #x7a #x8c #xcd))) 250.55 0.01)
|
|
|
|
|
(check-equal? (size floatbe) 4)
|
|
|
|
|
(check-equal? (encode floatbe #f 250.55) (bytes #x43 #x7a #x8c #xcd))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'floatle', ->
|
|
|
|
@ -459,9 +459,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(check-= (send floatle decode (+DecodeStream (bytes #xcd #x8c #x7a #x43))) 250.55 0.01)
|
|
|
|
|
(check-equal? (send floatle size) 4)
|
|
|
|
|
(check-equal? (send floatle encode #f 250.55) (bytes #xcd #x8c #x7a #x43))
|
|
|
|
|
(check-= (decode floatle (+DecodeStream (bytes #xcd #x8c #x7a #x43))) 250.55 0.01)
|
|
|
|
|
(check-equal? (size floatle) 4)
|
|
|
|
|
(check-equal? (encode floatle #f 250.55) (bytes #xcd #x8c #x7a #x43))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'double', ->
|
|
|
|
@ -469,7 +469,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; double.should.equal doublebe
|
|
|
|
|
|
|
|
|
|
;; modified test: `double` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send double decode (bytes 0 1 2 3 4 5 6 7)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode double (bytes 0 1 2 3 4 5 6 7)) (send (if (system-big-endian?)
|
|
|
|
|
doublebe
|
|
|
|
|
doublele) decode (bytes 0 1 2 3 4 5 6 7)))
|
|
|
|
|
|
|
|
|
@ -491,9 +491,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; doublebe.encode(stream, 1234.56)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send doublebe decode (+DecodeStream (bytes #x40 #x93 #x4a #x3d #x70 #xa3 #xd7 #x0a))) 1234.56)
|
|
|
|
|
(check-equal? (send doublebe size) 8)
|
|
|
|
|
(check-equal? (send doublebe encode #f 1234.56) (bytes #x40 #x93 #x4a #x3d #x70 #xa3 #xd7 #x0a))
|
|
|
|
|
(check-equal? (decode doublebe (+DecodeStream (bytes #x40 #x93 #x4a #x3d #x70 #xa3 #xd7 #x0a))) 1234.56)
|
|
|
|
|
(check-equal? (size doublebe) 8)
|
|
|
|
|
(check-equal? (encode doublebe #f 1234.56) (bytes #x40 #x93 #x4a #x3d #x70 #xa3 #xd7 #x0a))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'doublele', ->
|
|
|
|
@ -513,9 +513,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; doublele.encode(stream, 1234.56)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-equal? (send doublele decode (+DecodeStream (bytes #x0a #xd7 #xa3 #x70 #x3d #x4a #x93 #x40))) 1234.56)
|
|
|
|
|
(check-equal? (send doublele size) 8)
|
|
|
|
|
(check-equal? (send doublele encode #f 1234.56) (bytes #x0a #xd7 #xa3 #x70 #x3d #x4a #x93 #x40))
|
|
|
|
|
(check-equal? (decode doublele (+DecodeStream (bytes #x0a #xd7 #xa3 #x70 #x3d #x4a #x93 #x40))) 1234.56)
|
|
|
|
|
(check-equal? (size doublele) 8)
|
|
|
|
|
(check-equal? (encode doublele #f 1234.56) (bytes #x0a #xd7 #xa3 #x70 #x3d #x4a #x93 #x40))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'fixed16', ->
|
|
|
|
@ -523,7 +523,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed16.should.equal fixed16be
|
|
|
|
|
|
|
|
|
|
;; modified test: `fixed16` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send fixed16 decode (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode fixed16 (bytes 0 1)) (send (if (system-big-endian?)
|
|
|
|
|
fixed16be
|
|
|
|
|
fixed16le) decode (bytes 0 1)))
|
|
|
|
|
|
|
|
|
@ -545,9 +545,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed16be.encode(stream, 25.34)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-= (send fixed16be decode (+DecodeStream (bytes #x19 #x57))) 25.34 0.01)
|
|
|
|
|
(check-equal? (send fixed16be size) 2)
|
|
|
|
|
(check-equal? (send fixed16be encode #f 25.34) (bytes #x19 #x57))
|
|
|
|
|
(check-= (decode fixed16be (+DecodeStream (bytes #x19 #x57))) 25.34 0.01)
|
|
|
|
|
(check-equal? (size fixed16be) 2)
|
|
|
|
|
(check-equal? (encode fixed16be #f 25.34) (bytes #x19 #x57))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'fixed16le', ->
|
|
|
|
@ -567,9 +567,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed16le.encode(stream, 25.34)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-= (send fixed16le decode (+DecodeStream (bytes #x57 #x19))) 25.34 0.01)
|
|
|
|
|
(check-equal? (send fixed16le size) 2)
|
|
|
|
|
(check-equal? (send fixed16le encode #f 25.34) (bytes #x57 #x19))
|
|
|
|
|
(check-= (decode fixed16le (+DecodeStream (bytes #x57 #x19))) 25.34 0.01)
|
|
|
|
|
(check-equal? (size fixed16le) 2)
|
|
|
|
|
(check-equal? (encode fixed16le #f 25.34) (bytes #x57 #x19))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'fixed32', ->
|
|
|
|
@ -577,7 +577,7 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed32.should.equal fixed32be
|
|
|
|
|
|
|
|
|
|
;; modified test: `fixed32` is the same endianness as the platform
|
|
|
|
|
(check-equal? (send fixed32 decode (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
(check-equal? (decode fixed32 (bytes 0 1 2 3)) (send (if (system-big-endian?)
|
|
|
|
|
fixed32be
|
|
|
|
|
fixed32le) decode (bytes 0 1 2 3)))
|
|
|
|
|
|
|
|
|
@ -599,9 +599,9 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed32be.encode(stream, 250.55)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-= (send fixed32be decode (+DecodeStream (bytes #x00 #xfa #x8c #xcc))) 250.55 0.01)
|
|
|
|
|
(check-equal? (send fixed32be size) 4)
|
|
|
|
|
(check-equal? (send fixed32be encode #f 250.55) (bytes #x00 #xfa #x8c #xcc))
|
|
|
|
|
(check-= (decode fixed32be (+DecodeStream (bytes #x00 #xfa #x8c #xcc))) 250.55 0.01)
|
|
|
|
|
(check-equal? (size fixed32be) 4)
|
|
|
|
|
(check-equal? (encode fixed32be #f 250.55) (bytes #x00 #xfa #x8c #xcc))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
; describe 'fixed32le', ->
|
|
|
|
@ -621,6 +621,6 @@ https://github.com/mbutterick/restructure/blob/master/test/Number.coffee
|
|
|
|
|
; fixed32le.encode(stream, 250.55)
|
|
|
|
|
; stream.end()
|
|
|
|
|
|
|
|
|
|
(check-= (send fixed32le decode (+DecodeStream (bytes #xcc #x8c #xfa #x00))) 250.55 0.01)
|
|
|
|
|
(check-equal? (send fixed32le size) 4)
|
|
|
|
|
(check-equal? (send fixed32le encode #f 250.55) (bytes #xcc #x8c #xfa #x00))
|
|
|
|
|
(check-= (decode fixed32le (+DecodeStream (bytes #xcc #x8c #xfa #x00))) 250.55 0.01)
|
|
|
|
|
(check-equal? (size fixed32le) 4)
|
|
|
|
|
(check-equal? (encode fixed32le #f 250.55) (bytes #xcc #x8c #xfa #x00))
|