Skip to content

Commit

Permalink
add Bit-Vector Arithmetic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thephoeron committed Jul 5, 2015
1 parent 9c44c22 commit dd187a7
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion t/bit-smasher.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

;; NOTE: To run this test file, execute `(asdf:test-system :bit-smasher)' in your Lisp.

(plan 3)
(plan 4)

(deftest sanity-check
(pass "PROVE is loaded and ready to go.")
Expand All @@ -22,6 +22,42 @@
4
"Multiplication: (* 2 2) => 4."))

;; Bit-Vector Arithmetic Test

(deftest arithmetic
(is (bit+ #*0010 #*1000)
#*00001010
:test #'equal
"Sum of two bit-vectors.")
(is (bit- #*1000 #*0010)
#*00000110
:test #'equal
"Difference of two bit-vectors.")
(is (bit* #*1000 #*0010)
#*00010000
:test #'equal
"Product of two bit-vectors.")
(is (bit/ #*1000 #*0010)
#*00000100
:test #'equal
"Quotient of two bit-vectors.")
(is (bit-floor #*1000 #*0010)
#*00000100
:test #'equal
"Floor-Division of two bit-vectors.")
(is (bit-ceiling #*1000 #*0010)
#*00000100
:test #'equal
"Ceiling-Division of two bit-vectors.")
(is (<< #*0010 2)
#*00001000
:test #'equal
"Left-shift Bit-Vector by two bits.")
(is (>> #*1000 2)
#*00000010
:test #'equal
"Right-shift Bit-Vector by two bits."))

;; Conversion test

(deftest conversion
Expand Down

0 comments on commit dd187a7

Please sign in to comment.