Merge pull request #1 from taksatou/master

fix (pack "w" 0)
This commit is contained in:
Dan Ballard 2012-11-11 09:49:16 -08:00
commit 94187ec3a2
2 changed files with 3 additions and 0 deletions

View File

@ -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

View File

@ -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 ()