|
2 | 2 | (:require [clojure.test :refer [deftest testing is]] |
3 | 3 | simple-cipher)) |
4 | 4 |
|
5 | | -(deftest rand-key_test_1 |
| 5 | +(deftest ^:rand-key rand-key_test_1 |
6 | 6 | (testing "Random key cipher ▶ Key is made only of lowercase letters" |
7 | 7 | (is (true? (boolean (re-matches #"^[a-z]+$" (simple-cipher/rand-key))))))) |
8 | 8 |
|
9 | | -(deftest encode_test_1 |
| 9 | +(deftest ^:encode encode_test_1 |
10 | 10 | (testing "Random key cipher ▶ Can encode" |
11 | 11 | (let [key (simple-cipher/rand-key)] |
12 | 12 | (is (= (subs key 0 (count "aaaaaaaaaa")) (simple-cipher/encode key "aaaaaaaaaa")))))) |
13 | 13 |
|
14 | | -(deftest encode_test_2 |
| 14 | +(deftest ^:encode encode_test_2 |
15 | 15 | (testing "Substitution cipher ▶ Can encode" |
16 | 16 | (is (= "abcdefghij" (simple-cipher/encode "abcdefghij" "aaaaaaaaaa"))))) |
17 | 17 |
|
18 | | -(deftest encode_test_3 |
| 18 | +(deftest ^:encode encode_test_3 |
19 | 19 | (testing "Substitution cipher ▶ Can double shift encode" |
20 | 20 | (is (= "qayaeaagaciai" (simple-cipher/encode "iamapandabear" "iamapandabear"))))) |
21 | 21 |
|
22 | | -(deftest encode_test_4 |
| 22 | +(deftest ^:encode encode_test_4 |
23 | 23 | (testing "Substitution cipher ▶ Can wrap on encode" |
24 | 24 | (is (= "zabcdefghi" (simple-cipher/encode "abcdefghij" "zzzzzzzzzz"))))) |
25 | 25 |
|
26 | | -(deftest encode_test_5 |
| 26 | +(deftest ^:encode encode_test_5 |
27 | 27 | (testing "Substitution cipher ▶ Can encode messages longer than the key" |
28 | 28 | (is (= "iboaqcnecbfcr" (simple-cipher/encode "abc" "iamapandabear"))))) |
29 | 29 |
|
30 | | -(deftest decode_test_1 |
| 30 | +(deftest ^:decode decode_test_1 |
31 | 31 | (testing "Random key cipher ▶ Can decode" |
32 | 32 | (let [key (simple-cipher/rand-key)] |
33 | 33 | (is (= "aaaaaaaaaa" (simple-cipher/decode key (subs key 0 (count "aaaaaaaaaa")))))))) |
34 | 34 |
|
35 | | -(deftest decode_test_2 |
| 35 | +(deftest ^:decode decode_test_2 |
36 | 36 | (testing "Random key cipher ▶ Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method" |
37 | 37 | (let [key (simple-cipher/rand-key)] |
38 | 38 | (is (= "abcdefghij" (simple-cipher/decode key (simple-cipher/encode key "abcdefghij"))))))) |
39 | 39 |
|
40 | | -(deftest decode_test_3 |
| 40 | +(deftest ^:decode decode_test_3 |
41 | 41 | (testing "Substitution cipher ▶ Can decode" |
42 | 42 | (is (= "aaaaaaaaaa" (simple-cipher/decode "abcdefghij" "abcdefghij"))))) |
43 | 43 |
|
44 | | -(deftest decode_test_4 |
| 44 | +(deftest ^:decode decode_test_4 |
45 | 45 | (testing "Substitution cipher ▶ Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method" |
46 | 46 | (is (= "abcdefghij" (simple-cipher/decode "abcdefghij" (simple-cipher/encode "abcdefghij" "abcdefghij")))))) |
47 | 47 |
|
48 | | -(deftest decode_test_5 |
| 48 | +(deftest ^:decode decode_test_5 |
49 | 49 | (testing "Substitution cipher ▶ Can wrap on decode" |
50 | 50 | (is (= "zzzzzzzzzz" (simple-cipher/decode "abcdefghij" "zabcdefghi"))))) |
51 | 51 |
|
52 | | -(deftest decode_test_6 |
| 52 | +(deftest ^:decode decode_test_6 |
53 | 53 | (testing "Substitution cipher ▶ Can decode messages longer than the key" |
54 | 54 | (is (= "iamapandabear" (simple-cipher/decode "abc" "iboaqcnecbfcr"))))) |
0 commit comments