|
|
|
@ -31,12 +31,12 @@ https://github.com/mbutterick/restructure/blob/master/test/Array.coffee
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode length from parent key"
|
|
|
|
|
(parameterize ([current-input-port (open-input-bytes (bytes 1 2 3 4 5))])
|
|
|
|
|
(check-equal? (send (+xarray #:type uint8 #:length 'len) xxdecode (current-input-port) (mhash 'len 4)) '(1 2 3 4))))
|
|
|
|
|
(check-equal? (decode (+xarray #:type uint8 #:length 'len) (current-input-port) #:parent (mhash 'len 4)) '(1 2 3 4))))
|
|
|
|
|
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode byte count from parent key"
|
|
|
|
|
(parameterize ([current-input-port (open-input-bytes (bytes 1 2 3 4 5))])
|
|
|
|
|
(check-equal? (send (+xarray #:type uint16be #:length 'len #:count-bytes #t) xxdecode (current-input-port) (mhash 'len 4)) '(258 772))))
|
|
|
|
|
(check-equal? (decode (+xarray #:type uint16be #:length 'len #:count-bytes #t) (current-input-port) #:parent (mhash 'len 4)) '(258 772))))
|
|
|
|
|
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode length as number before array"
|
|
|
|
@ -61,12 +61,12 @@ https://github.com/mbutterick/restructure/blob/master/test/Array.coffee
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode to the end of parent if no length given"
|
|
|
|
|
(parameterize ([current-input-port (open-input-bytes (bytes 1 2 3 4 5))])
|
|
|
|
|
(check-equal? (send (+xarray #:type uint8) xxdecode (current-input-port) (mhash '_length 4 '_startOffset 0)) '(1 2 3 4))))
|
|
|
|
|
(check-equal? (decode (+xarray #:type uint8) (current-input-port) #:parent (mhash '_length 4 '_startOffset 0)) '(1 2 3 4))))
|
|
|
|
|
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode to the end of the stream if parent exists, but its length is 0"
|
|
|
|
|
(parameterize ([current-input-port (open-input-bytes (bytes 1 2 3 4 5))])
|
|
|
|
|
(check-equal? (send (+xarray #:type uint8) xxdecode (current-input-port) (mhash '_length 0 '_startOffset 0)) '(1 2 3 4 5))))
|
|
|
|
|
(check-equal? (decode (+xarray #:type uint8) (current-input-port) #:parent (mhash '_length 0 '_startOffset 0)) '(1 2 3 4 5))))
|
|
|
|
|
|
|
|
|
|
(test-case
|
|
|
|
|
"array: decode to the end of the stream if no parent and length is given"
|
|
|
|
|