rivo committed 136699d Merge

Merged in sjamaan/bitstring (pull request #2)

Error during resizing calculation due to incomplete division, and improve tests by wrapping them in a big group

Comments (0)

Files changed (2)

       	  (abort "not implemented for this buffer type"))))))
 (define (bitstring-buffer-resize bs size-in-bits)
-  (let* ((new-size (inexact->exact (/ size-in-bits 8)))
+  (let* ((new-size (inexact->exact (ceiling (/ size-in-bits 8))))
          (tmp (make-u8vector new-size 0))
          (used (bitstring-buffer-size bs)))
     (let copy ((i 0)
 (test (bitconstruct (1)) (bitconstruct (foo bitstring)))
+(test-begin "bitstring")
 (test-begin "integer attributes")
 (define bstr (bitstring-of-any "\xff"))
 (test -127 (bitmatch bstr ((x signed) -> x)))
 ; append with resize
 (define bs (bitstring-create))
 (let ((a "Is There Love")
-      (b "in Space?"))
+      (b "in Space?")
+      (c "Nobody knows."))
   (bitstring-append bs (bitstring-of-any a))
   (bitstring-append bs (bitstring-of-any b))
-  (test #t (bitstring=? (bitstring-of-any (string-append a b)) bs)))
+  (test #t (bitstring=? (bitstring-of-any (string-append a b)) bs))
+  (bitstring-append bs (bitstring-of-any c))
+  (test #t (bitstring=? (bitstring-of-any (string-append a b c)) bs)))
 (test-begin "bitpacket")
 (test `(0 32 #u8( #x6D #xE7 #xFB #xBD)) (get-fields (single->bitstring -0.123)))
+(test-end "bitstring")