commit
94187ec3a2
|
@ -152,6 +152,7 @@
|
||||||
"function to encode a BER number into a binary byte string"
|
"function to encode a BER number into a binary byte string"
|
||||||
(let ((num_bytes (ceiling (/ (log (1+ number) 2) 7)))
|
(let ((num_bytes (ceiling (/ (log (1+ number) 2) 7)))
|
||||||
(n number))
|
(n number))
|
||||||
|
(if (eql 0 n) (incf num_bytes))
|
||||||
(coerce (loop for i from (1- num_bytes) downto 0 collect
|
(coerce (loop for i from (1- num_bytes) downto 0 collect
|
||||||
(code-char (+ (if (> i 0)
|
(code-char (+ (if (> i 0)
|
||||||
128
|
128
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
(string= (pack "E" 25) (concatenate 'string (gen-null-string 6) "9@"))
|
(string= (pack "E" 25) (concatenate 'string (gen-null-string 6) "9@"))
|
||||||
(string= (pack "x") (string #\null))
|
(string= (pack "x") (string #\null))
|
||||||
(string= (pack "w" 193) (coerce `(,(code-char 129) #\A) 'string))
|
(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 "G" (concatenate 'string "@9" (gen-null-string 6))) 25)
|
||||||
(= (unpack "E" (concatenate 'string (gen-null-string 6) "9@")) 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 129) #\A) 'string)) 193)
|
||||||
|
(= (unpack "w" (coerce `(,(code-char 0)) 'string)) 0)
|
||||||
))
|
))
|
||||||
|
|
||||||
(deftest unpack-combinations ()
|
(deftest unpack-combinations ()
|
||||||
|
|
Loading…
Reference in New Issue