Fix `equal?' on bytevectors.
authorLudovic Courtès <ludo@gnu.org>
Thu, 18 Jun 2009 22:10:21 +0000 (00:10 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 18 Jun 2009 22:10:21 +0000 (00:10 +0200)
* libguile/bytevectors.c (bytevector_equal_p): New function.

* test-suite/tests/bytevectors.test ("2.3 Operations on Bytes and
  Octets")["equal?"]: New test.

libguile/bytevectors.c
test-suite/tests/bytevectors.test

index 0846d91..2484a64 100644 (file)
@@ -300,6 +300,11 @@ SCM_SMOB_PRINT (scm_tc16_bytevector, print_bytevector,
   return 1;
 }
 
+SCM_SMOB_EQUALP (scm_tc16_bytevector, bytevector_equal_p, bv1, bv2)
+{
+  return scm_bytevector_eq_p (bv1, bv2);
+}
+
 SCM_SMOB_FREE (scm_tc16_bytevector, free_bytevector, bv)
 {
 
index c7697b1..95d6c40 100644 (file)
       (bytevector-sint-set! b 0 -16 (endianness big) 2)
       (bytevector-sint-set! b 1 -16 (endianness little) 2)
       (equal? (bytevector->u8-list b)
-             '(#xff #xf0 #xff)))))
+             '(#xff #xf0 #xff))))
+
+  (pass-if "equal?"
+    (let ((bv1 (u8-list->bytevector (iota 123)))
+          (bv2 (u8-list->bytevector (iota 123))))
+      (equal? bv1 bv2))))
 
 \f
 (with-test-prefix "2.4 Operations on Integers of Arbitrary Size"