emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 702d9d8 4/5: Add new tests to bindat-tests.el


From: Stefan Kangas
Subject: master 702d9d8 4/5: Add new tests to bindat-tests.el
Date: Wed, 29 Apr 2020 07:10:59 -0400 (EDT)

branch: master
commit 702d9d86f2a7ba9df693a1140565aa111135f1bb
Author: Stefan Kangas <address@hidden>
Commit: Stefan Kangas <address@hidden>

    Add new tests to bindat-tests.el
    
    * test/lisp/emacs-lisp/bindat-tests.el (bindat-test-format-vector)
    (bindat-test-vector-to-dec, bindat-test-vector-to-hex)
    (bindat-test-ip-to-string): New tests.
    * lisp/emacs-lisp/bindat.el (bindat-vector-to-hex): Fix typo.
---
 lisp/emacs-lisp/bindat.el            |  2 +-
 test/lisp/emacs-lisp/bindat-tests.el | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index b5d99e3..d168c25 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -632,7 +632,7 @@ If optional second arg SEP is a string, use that as 
separator."
   (bindat-format-vector vect "%d" (if (stringp sep) sep ".")))
 
 (defun bindat-vector-to-hex (vect &optional sep)
-  "Format vector VECT in hex format separated by dots.
+  "Format vector VECT in hex format separated by colons.
 If optional second arg SEP is a string, use that as separator."
   (bindat-format-vector vect "%02x" (if (stringp sep) sep ":")))
 
diff --git a/test/lisp/emacs-lisp/bindat-tests.el 
b/test/lisp/emacs-lisp/bindat-tests.el
index f8efa79..14f95a8 100644
--- a/test/lisp/emacs-lisp/bindat-tests.el
+++ b/test/lisp/emacs-lisp/bindat-tests.el
@@ -96,4 +96,20 @@
               (dest-ip .
                       [192 168 1 100]))))))
 
+(ert-deftest bindat-test-format-vector ()
+  (should (equal (bindat-format-vector [1 2 3] "%d" "x" 2) "1x2"))
+  (should (equal (bindat-format-vector [1 2 3] "%d" "x") "1x2x3")))
+
+(ert-deftest bindat-test-vector-to-dec ()
+  (should (equal (bindat-vector-to-dec [1 2 3]) "1.2.3"))
+  (should (equal (bindat-vector-to-dec [2048 1024 512] ".") "2048.1024.512")))
+
+(ert-deftest bindat-test-vector-to-hex ()
+  (should (equal (bindat-vector-to-hex [1 2 3]) "01:02:03"))
+  (should (equal (bindat-vector-to-hex [2048 1024 512] ".") "800.400.200")))
+
+(ert-deftest bindat-test-ip-to-string ()
+  (should (equal (bindat-ip-to-string [192 168 0 1]) "192.168.0.1"))
+  (should (equal (bindat-ip-to-string "\300\250\0\1") "192.168.0.1")))
+
 ;;; bindat-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]