added testcases bytevector.rkt:bytevector-section
This commit is contained in:
parent
3cf9feed7d
commit
054047f915
1 changed files with 21 additions and 0 deletions
|
@ -69,3 +69,24 @@
|
||||||
(f v 0 n (endianness big))
|
(f v 0 n (endianness big))
|
||||||
v)))
|
v)))
|
||||||
|
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(require rackunit)
|
||||||
|
|
||||||
|
(test-begin
|
||||||
|
(let [(long-vec (bytes 10 20 30 40 50))]
|
||||||
|
(check-equal? (bytevector-section long-vec 0 2)
|
||||||
|
(bytes 10 20))
|
||||||
|
(check-equal? (bytevector-section long-vec 0 (bytes-length long-vec))
|
||||||
|
long-vec)
|
||||||
|
;; bytevector-section is equivalent ot subbytes
|
||||||
|
(check-equal? (bytevector-section long-vec 1 3)
|
||||||
|
(subbytes long-vec 1 3))
|
||||||
|
|
||||||
|
|
||||||
|
; check if exceding limits raises exception
|
||||||
|
(check-exn exn:fail? (λ () (bytevector-section long-vec 0 30)))
|
||||||
|
(check-exn exn:fail? (λ () (bytevector-section long-vec -1 3)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
Loading…
Reference in a new issue