Skip to content

Commit 6ba4b70

Browse files
authored
simple-cipher: Fix generator and regenerate tests (#841)
1 parent d5c3a0c commit 6ba4b70

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

exercises/practice/simple-cipher/.meta/generator.tpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
(is (= {{expected}} (simple-cipher/encode {{input.key}} {{input.plaintext}})))))
1616
{{else~}}
1717
(let [key (simple-cipher/rand-key)]
18-
(is (= (subs key 0 (count {{input.plaintext}})) (simple-cipher/encode key {{input.plaintext}}))))))
18+
(is (= (subs key 0 (count {{input.plaintext}})) (simple-cipher/encode key {{input.plaintext}}))))))
1919
{{/if~}}
2020
{{/test_cases.encode}}
2121

2222
{{#test_cases.decode}}
2323
(deftest decode_test_{{idx}}
2424
(testing {{context}}
2525
{{#if input.key~}}
26-
(is (= {{expected}} (simple-cipher/decode {{input.key}} {{#if input.plaintext}}(simple-cipher/encode {{input.key}} {{input.plaintext}}{{else}}{{input.ciphertext}}{{/if}}))))))
26+
(is (= {{expected}} (simple-cipher/decode {{input.key}} {{#if input.plaintext}}(simple-cipher/encode {{input.key}} {{input.plaintext}}){{else}}{{input.ciphertext}}{{/if}})))))
2727
{{else~}}
2828
(let [key (simple-cipher/rand-key)]
29-
(is (= {{expected}} (simple-cipher/decode key {{#if input.plaintext}}(simple-cipher/encode key {{input.plaintext}}{{else}}(subs key 0 (count {{expected}})){{/if}})))))
29+
(is (= {{expected}} (simple-cipher/decode key {{#if input.plaintext}}(simple-cipher/encode key {{input.plaintext}}){{else}}(subs key 0 (count {{expected}})){{/if}}))))))
3030
{{/if~}}
3131
{{/test_cases.decode}}

exercises/practice/simple-cipher/test/simple_cipher_test.clj

+17-17
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@
3030
(deftest decode_test_1
3131
(testing "Random key cipher ▶ Can decode"
3232
(let [key (simple-cipher/rand-key)]
33-
(is (= "aaaaaaaaaa" (simple-cipher/decode key (subs key 0 (count "aaaaaaaaaa")))))))
33+
(is (= "aaaaaaaaaa" (simple-cipher/decode key (subs key 0 (count "aaaaaaaaaa"))))))))
3434

35-
(deftest decode_test_2
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-
(let [key (simple-cipher/rand-key)]
38-
(is (= "abcdefghij" (simple-cipher/decode key (simple-cipher/encode key "abcdefghij")))))
35+
(deftest decode_test_2
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+
(let [key (simple-cipher/rand-key)]
38+
(is (= "abcdefghij" (simple-cipher/decode key (simple-cipher/encode key "abcdefghij")))))))
3939

40-
(deftest decode_test_3
41-
(testing "Substitution cipher ▶ Can decode"
42-
(is (= "aaaaaaaaaa" (simple-cipher/decode "abcdefghij" "abcdefghij"))))))
40+
(deftest decode_test_3
41+
(testing "Substitution cipher ▶ Can decode"
42+
(is (= "aaaaaaaaaa" (simple-cipher/decode "abcdefghij" "abcdefghij")))))
4343

44-
(deftest decode_test_4
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-
(is (= "abcdefghij" (simple-cipher/decode "abcdefghij" (simple-cipher/encode "abcdefghij" "abcdefghij"))))))
44+
(deftest decode_test_4
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+
(is (= "abcdefghij" (simple-cipher/decode "abcdefghij" (simple-cipher/encode "abcdefghij" "abcdefghij"))))))
4747

48-
(deftest decode_test_5
49-
(testing "Substitution cipher ▶ Can wrap on decode"
50-
(is (= "zzzzzzzzzz" (simple-cipher/decode "abcdefghij" "zabcdefghi"))))))
48+
(deftest decode_test_5
49+
(testing "Substitution cipher ▶ Can wrap on decode"
50+
(is (= "zzzzzzzzzz" (simple-cipher/decode "abcdefghij" "zabcdefghi")))))
5151

52-
(deftest decode_test_6
53-
(testing "Substitution cipher ▶ Can decode messages longer than the key"
54-
(is (= "iamapandabear" (simple-cipher/decode "abc" "iboaqcnecbfcr"))))))
52+
(deftest decode_test_6
53+
(testing "Substitution cipher ▶ Can decode messages longer than the key"
54+
(is (= "iamapandabear" (simple-cipher/decode "abc" "iboaqcnecbfcr")))))

0 commit comments

Comments
 (0)