59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
;; Function To Be Tested: dpb
|
|
;;
|
|
;; Source: Common Lisp by Guy Steele
|
|
;; Section 12.8: Byte Manipulation Functions
|
|
;; on Numbers Page: 227
|
|
;;
|
|
;; Created By: John Park
|
|
;;
|
|
;; Creation Date: July 24, 86
|
|
;;
|
|
;; Last Update:
|
|
;;
|
|
;; Filed as: {eris}<lispcore>cml>test>12-8-dpb.test
|
|
;;
|
|
;; Syntax: dpb newbyte bytespec integer
|
|
;;
|
|
;; Function Description: This returns a number that is the same as integer
|
|
;; except in the bits specified by bytespec. Let s be the size specified by
|
|
;; bytespec; then the low s bits of newbyte appear in the result in the byte
|
|
;; specified by bytespec. The integer newbyte is therefore interpreted as
|
|
;; being right-justified, as if it were the result of ldb.
|
|
;; (logbitp j (dpb m (byte s p) n))
|
|
;; => (if (and (>= j p) (< j (+ p s))) (logbitp (- j p) m) (logbitp j n))
|
|
;;
|
|
;; Argument(s): newbyte bytespec: list integer
|
|
;;
|
|
;; Returns: non-negative integer
|
|
;;
|
|
;; Constraints/limitations: None
|
|
|
|
(do-test-group dpb-setup
|
|
:before (progn
|
|
(setq byte-spec8-0 (byte 8 0))
|
|
(setq byte-spec8-1 (byte 8 1))
|
|
(setq byte-spec8-2 (byte 8 2))
|
|
(setq byte-spec8-3 (byte 8 3))
|
|
(setq byte-spec8-4 (byte 8 4)))
|
|
|
|
|
|
(do-test dpb-test
|
|
(and (eq (dpb 1 byte-spec8-0 15) 1)
|
|
(eq (dpb 1 byte-spec8-1 15) 3)
|
|
(eq (dpb 1 byte-spec8-2 15) 7)
|
|
(eq (dpb 1 byte-spec8-3 15) 15)
|
|
(eq (dpb 1 byte-spec8-4 15) 31)
|
|
(eq (dpb 3 byte-spec8-0 15) 3)
|
|
(eq (dpb 3 byte-spec8-1 15) 7)
|
|
(eq (dpb 3 byte-spec8-2 15) 15)
|
|
(eq (dpb 3 byte-spec8-3 15) 31)
|
|
(eq (dpb 3 byte-spec8-4 15) 63)
|
|
(eq (dpb 5 byte-spec8-0 15) 5)
|
|
(eq (dpb 5 byte-spec8-1 15) 11)
|
|
(eq (dpb 5 byte-spec8-2 15) 23)
|
|
(eq (dpb 5 byte-spec8-3 15) 47)
|
|
(eq (dpb 5 byte-spec8-4 15) 95))))
|
|
|
|
STOP
|
|
|