aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob1312021-09-06 09:53:01 +1000
committerArun Isaac2021-09-07 01:24:00 +0530
commitcfe5d8257a713bda49f7d9d6032d6e83cb7e175c (patch)
tree63bdf4a2f8f7735523fa30e841a4ee6ee923ec02 /tests
parent007890b634cd782ed09bae1368df561815c27d9f (diff)
downloadguile-xapian-cfe5d8257a713bda49f7d9d6032d6e83cb7e175c.tar.gz
guile-xapian-cfe5d8257a713bda49f7d9d6032d6e83cb7e175c.tar.lz
guile-xapian-cfe5d8257a713bda49f7d9d6032d6e83cb7e175c.zip
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 <arunisaac@systemreboot.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/xapian.scm17
1 files changed, 17 insertions, 0 deletions
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 <arunisaac@systemreboot.net>
+;;; Copyright © 2021 Bob131 <bob@bob131.so>
;;;
;;; 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")