2007-05-15 12:29:47 -04:00
|
|
|
|
|
|
|
(library (tests bytevectors)
|
|
|
|
(export test-bytevectors)
|
|
|
|
(import (ikarus) (tests framework))
|
|
|
|
|
2007-05-15 12:42:52 -04:00
|
|
|
(define (not-bytevector? x)
|
2007-05-15 12:29:47 -04:00
|
|
|
(not (bytevector? x)))
|
|
|
|
|
|
|
|
(define-tests test-bytevectors
|
|
|
|
[bytevector? (make-bytevector 1)]
|
|
|
|
[bytevector? (make-bytevector 1 17)]
|
|
|
|
[bytevector? (make-bytevector 10 -17)]
|
|
|
|
[not-bytevector? 'foo]
|
|
|
|
[not-bytevector? "hey"]
|
|
|
|
[not-bytevector? (current-output-port)]
|
|
|
|
[not-bytevector? (current-input-port)]
|
|
|
|
[not-bytevector? '#(2837 2398 239)]
|
2007-05-15 13:17:17 -04:00
|
|
|
[zero? (bytevector-length (make-bytevector 0))]
|
|
|
|
[(lambda (x) (= x 100)) (bytevector-length (make-bytevector 100 -30))]
|
2007-05-15 13:38:38 -04:00
|
|
|
[(lambda (x) (equal? x '(-127 129 -1 255)))
|
|
|
|
(let ([b1 (make-bytevector 16 -127)]
|
|
|
|
[b2 (make-bytevector 16 255)])
|
|
|
|
(list
|
|
|
|
(bytevector-s8-ref b1 0)
|
|
|
|
(bytevector-u8-ref b1 0)
|
|
|
|
(bytevector-s8-ref b2 0)
|
|
|
|
(bytevector-u8-ref b2 0)))]
|
2007-05-15 13:50:00 -04:00
|
|
|
[(lambda (x) (equal? x '(-126 130 -10 246)))
|
|
|
|
(let ([b (make-bytevector 16 -127)])
|
|
|
|
(bytevector-s8-set! b 0 -126)
|
|
|
|
(bytevector-u8-set! b 1 246)
|
|
|
|
(list
|
|
|
|
(bytevector-s8-ref b 0)
|
|
|
|
(bytevector-u8-ref b 0)
|
|
|
|
(bytevector-s8-ref b 1)
|
|
|
|
(bytevector-u8-ref b 1)))]
|
2007-05-15 13:17:17 -04:00
|
|
|
|
2007-05-15 12:29:47 -04:00
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|