summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/bindat-tests.el
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-10-30 18:45:37 +0100
committerPhilip Kaludercic <philipk@posteo.net>2022-10-30 18:45:37 +0100
commit2a4f37fe520b4f18295cff6671f289a47c1578df (patch)
tree6061489df433080d5a3da4a8eb33fd269d2bcb95 /test/lisp/emacs-lisp/bindat-tests.el
parentd33998ed3b5e05a40b9c4c1799b6e911b582ef01 (diff)
parent3fa4cca3d244f51e471e7779c934278731fc21e9 (diff)
downloademacs-2a4f37fe520b4f18295cff6671f289a47c1578df.tar.gz
emacs-2a4f37fe520b4f18295cff6671f289a47c1578df.tar.bz2
emacs-2a4f37fe520b4f18295cff6671f289a47c1578df.zip
Merge remote-tracking branch 'origin/master' into feature/package+vc
Diffstat (limited to 'test/lisp/emacs-lisp/bindat-tests.el')
-rw-r--r--test/lisp/emacs-lisp/bindat-tests.el19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/bindat-tests.el b/test/lisp/emacs-lisp/bindat-tests.el
index 0c03c51e2ef..2abf714852f 100644
--- a/test/lisp/emacs-lisp/bindat-tests.el
+++ b/test/lisp/emacs-lisp/bindat-tests.el
@@ -252,7 +252,24 @@
(should (equal (bindat-unpack spec "abc\0") "abc"))
;; Missing null terminator.
(should-error (bindat-unpack spec ""))
- (should-error (bindat-unpack spec "a"))))
+ (should-error (bindat-unpack spec "a")))
+
+ (ert-deftest bindat-test--strz-array-unpack ()
+ (should (equal (bindat-unpack spec [#x61 #x62 #x63 #x00]) "abc"))))
+
+(let ((spec (bindat-type str 3)))
+ (ert-deftest bindat-test--str-simple-array-unpack ()
+ (should (equal (bindat-unpack spec [#x61 #x62 #x63]) "abc"))))
+
+(let ((spec (bindat-type
+ (first u8)
+ (string str 3)
+ (last uint 16))))
+ (ert-deftest bindat-test--str-combined-array-unpack ()
+ (let ((unpacked (bindat-unpack spec [#xff #x63 #x62 #x61 #xff #xff])))
+ (should (equal (bindat-get-field unpacked 'string) "cba"))
+ (should (equal (bindat-get-field unpacked 'first) (- (expt 2 8) 1)))
+ (should (equal (bindat-get-field unpacked 'last) (- (expt 2 16) 1))))))
(let ((spec '((x strz 2))))
(ert-deftest bindat-test--strz-legacy-fixedlen-len ()