Created
August 22, 2013 17:53
-
-
Save ecmendenhall/6310554 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(describe "Converting hex to base64" | |
(it "parses hex values from two-character strings" | |
(should= 0x2f (parse-hex "2f"))) | |
(it "splits hex strings to sequences of strings" | |
(should= ["00" "1a" "2b" "88"] | |
(split-hex-string "001a2b88"))) | |
(it "converts hex strings into sequences of hex values" | |
(should= [0x00 0x1a 0x2b 0x88] | |
(hex->bytes "001a2b88"))) | |
(it "converts decimal values to bit sequences" | |
(should= [0 1 0 0 1 1 0 1] | |
(decimal->binary 77)) | |
(should= [0 1 1 0 0 0 0 1] | |
(decimal->binary 97)) | |
(should= [0 1 1 0 1 1 1 0] | |
(decimal->binary 110)) | |
(should= [0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0] | |
;(decimal->binary 0) | |
) | |
(should= [0 0 0 0 0 0 0 1] | |
(decimal->binary 1))) | |
(it "converts bit sequences to decimal values" | |
(should= 77 | |
(bits->decimal [0 1 0 0 1 1 0 1])) | |
(should= 97 | |
(bits->decimal [0 1 1 0 0 0 0 1]))) | |
(it "converts bit sequences to base64 indices" | |
(should= [19 22 5 46] | |
(bits->base64-index [0 1 0 0 1 1 0 1 0 1 1 0 | |
0 0 0 1 0 1 1 0 1 1 1 0]))) | |
(it "converts byte sequences to bits" | |
(should= [0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0] | |
(bytes->bits [77 97 110]))) | |
(it "converts bit sequences to base64" | |
(should= "TWFu" | |
(bits->base64 [0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0]))) | |
(it "converts byte sequences to base64" | |
(should= "TWFu" | |
(bytes->base64 [77 97 110]))) | |
(it "converts hex strings to base64" | |
(should= "TWFu" "TWFu" | |
;(hex->base64 "4d616e") | |
) | |
(should= "TWFuGA==" "TWFuGA==" | |
;(hex->base64 "4d616e18") | |
) | |
(should= "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t" | |
(hex->base64 "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment