Peter Bex committed 38b43d2

Fix new allocation for "buddy algorithm" size calculation, so it rounds properly instead of raising an inexact->exact error due to flonums.
Add surrounding main group to the tests, so that we get a total summary of total failed/passed subgroups at the end (very useful!)

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)
 (use srfi-4 bitstring test)
+(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")