Browse Source

Merge pull request #1 from taksatou/master

fix (pack "w" 0)
pull/3/head
Dan Ballard 9 years ago
parent
commit
94187ec3a2
  1. 1
      cl-pack.lisp
  2. 2
      tests.lisp

1
cl-pack.lisp

@ -152,6 +152,7 @@
"function to encode a BER number into a binary byte string"
(let ((num_bytes (ceiling (/ (log (1+ number) 2) 7)))
(n number))
(if (eql 0 n) (incf num_bytes))
(coerce (loop for i from (1- num_bytes) downto 0 collect
(code-char (+ (if (> i 0)
128

2
tests.lisp

@ -104,6 +104,7 @@
(string= (pack "E" 25) (concatenate 'string (gen-null-string 6) "9@"))
(string= (pack "x") (string #\null))
(string= (pack "w" 193) (coerce `(,(code-char 129) #\A) 'string))
(string= (pack "w" 0) (coerce `(,(code-char 0)) 'string))
))
@ -154,6 +155,7 @@
(= (unpack "G" (concatenate 'string "@9" (gen-null-string 6))) 25)
(= (unpack "E" (concatenate 'string (gen-null-string 6) "9@")) 25)
(= (unpack "w" (coerce `(,(code-char 129) #\A) 'string)) 193)
(= (unpack "w" (coerce `(,(code-char 0)) 'string)) 0)
))
(deftest unpack-combinations ()

Loading…
Cancel
Save