(import (rnrs) (srfi :64) (yuni core) (yuni binary bitstream)) (test-begin "yuni bitstream") (define (make-new-teststream) (define bv (u8-list->bytevector '(#x12 #x34 #x56 #x78 #x90))) (define port (open-bytevector-input-port bv)) (port->bitstream port 8 (endianness little))) (test-eq #t (is-a? (make-new-teststream) bitstream)) (let-with (make-new-teststream) (width/octet live?) (test-eq #t live?) (test-eq 1 width/octet)) (let () (define bs (make-new-teststream)) (define (read1) (bitstream-read bs 4)) (let* ((b (read1)) (a (read1)) (d (read1)) (c (read1)) (f (read1)) (e (read1)) (h (read1)) (g (read1)) (j (read1)) (i (read1))) (test-eq 1 a) (test-eq 2 b) (test-eq 3 c) (test-eq 4 d) (test-eq 5 e) (test-eq 6 f) (test-eq 7 g) (test-eq 8 h) (test-eq 9 i) (test-eq 0 j))) (let () (define bs (make-new-teststream)) (define (read1) (bitstream-read bs 4)) (let* ((b (read1)) (a (read1)) (d (read1)) (bogus (bitstream-skip-alignment bs 16)) ;(c (read1)) (f (read1)) (e (read1)) (h (read1)) (g (read1)) (j (read1)) (i (read1))) (test-eq 1 a) (test-eq 2 b) ;(test-eq 3 c) (test-eq 4 d) (test-eq 5 e) (test-eq 6 f) (test-eq 7 g) (test-eq 8 h) (test-eq 9 i) (test-eq 0 j))) (test-end "yuni bitstream")