From cfe5d8257a713bda49f7d9d6032d6e83cb7e175c Mon Sep 17 00:00:00 2001 From: Bob131 Date: Mon, 6 Sep 2021 09:53:01 +1000 Subject: tests: Add binary document tests. This commit adds tests to smoke-test document methods dealing with bytevectors. * tests/xapian.scm ("document-data fails to decode binary data", "document-bytes reads binary data correctly", "document-slot-ref fails to decode binary value", "document-slot-ref-bytes reads binary value correctly"): New tests. Signed-off-by: Arun Isaac --- tests/xapian.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/xapian.scm b/tests/xapian.scm index fd339e1..93d1a64 100644 --- a/tests/xapian.scm +++ b/tests/xapian.scm @@ -1,5 +1,6 @@ ;;; guile-xapian --- Guile bindings for Xapian ;;; Copyright © 2021 Arun Isaac +;;; Copyright © 2021 Bob131 ;;; ;;; This file is part of guile-xapian. ;;; @@ -22,4 +23,20 @@ (test-begin "xapian") +(let* ((invalid-utf8-data #vu8(#xf0 #x61 #x62 #x00)) + (binary-doc (make-document #:data invalid-utf8-data + #:values `((0 . ,invalid-utf8-data))))) + (test-error "document-data fails to decode binary data" + 'decoding-error + (document-data binary-doc)) + (test-equal "document-bytes reads binary data correctly" + invalid-utf8-data + (document-bytes binary-doc)) + (test-error "document-slot-ref fails to decode binary value" + 'decoding-error + (document-slot-ref binary-doc 0)) + (test-equal "document-slot-ref-bytes reads binary value correctly" + invalid-utf8-data + (document-slot-ref-bytes binary-doc 0))) + (test-end "xapian") -- cgit v1.2.3