Skip to content

Commit

Permalink
atbash-cipher: Add generators and regenerate tests (#806)
Browse files Browse the repository at this point in the history
* add generators and regenerate tests

* update function templates

* indicate why tests were excluded

[no important files changed]
  • Loading branch information
tasxatzial authored Feb 1, 2025
1 parent 96ec7db commit 7da2aec
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
5 changes: 5 additions & 0 deletions exercises/practice/atbash-cipher/.meta/generator.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns atbash-cipher-generator)

(defn update-test-case [test-case]
(-> test-case
(update :path #(take-last 1 %))))
17 changes: 17 additions & 0 deletions exercises/practice/atbash-cipher/.meta/generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns atbash-cipher-test
(:require [clojure.test :refer [deftest testing is]]
atbash-cipher))

{{#test_cases.encode}}
(deftest encode_test_{{idx}}
(testing {{description}}
(is (= {{expected}}
(atbash-cipher/encode {{input.phrase}})))))
{{/test_cases.encode}}

{{#test_cases.decode}}
(deftest decode_test_{{idx}}
(testing {{description}}
(is (= {{expected}}
(atbash-cipher/decode {{input.phrase}})))))
{{/test_cases.decode}}
2 changes: 2 additions & 0 deletions exercises/practice/atbash-cipher/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ description = "decode -> decode all the letters"
[39640287-30c6-4c8c-9bac-9d613d1a5674]
description = "decode -> decode with too many spaces"
include = false
comment = "not a valid encoded text"

[b34edf13-34c0-49b5-aa21-0768928000d5]
description = "decode -> decode with no spaces"
include = false
comment = "not a valid encoded text"
6 changes: 4 additions & 2 deletions exercises/practice/atbash-cipher/src/atbash_cipher.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
(ns atbash-cipher)

(defn encode
[s]
"Encodes the given text using the Atbash cipher."
[plaintext]
;; function body
)

(defn decode
[s]
"Decodes the given text using the Atbash cipher."
[ciphertext]
;; function body
)
26 changes: 13 additions & 13 deletions exercises/practice/atbash-cipher/test/atbash_cipher_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,61 @@
atbash-cipher))

(deftest encode_test_1
(testing "encode -> encode yes"
(testing "encode yes"
(is (= "bvh"
(atbash-cipher/encode "yes")))))

(deftest encode_test_2
(testing "encode -> encode no"
(testing "encode no"
(is (= "ml"
(atbash-cipher/encode "no")))))

(deftest encode_test_3
(testing "encode -> encode OMG"
(testing "encode OMG"
(is (= "lnt"
(atbash-cipher/encode "OMG")))))

(deftest encode_test_4
(testing "encode -> encode spaces"
(testing "encode spaces"
(is (= "lnt"
(atbash-cipher/encode "O M G")))))

(deftest encode_test_5
(testing "encode -> encode mindblowingly"
(testing "encode mindblowingly"
(is (= "nrmwy oldrm tob"
(atbash-cipher/encode "mindblowingly")))))

(deftest encode_test_6
(testing "encode -> encode numbers"
(testing "encode numbers"
(is (= "gvhgr mt123 gvhgr mt"
(atbash-cipher/encode "Testing, 1 2 3, testing.")))))
(atbash-cipher/encode "Testing,1 2 3, testing.")))))

(deftest encode_test_7
(testing "encode -> encode deep thought"
(testing "encode deep thought"
(is (= "gifgs rhurx grlm"
(atbash-cipher/encode "Truth is fiction.")))))

(deftest encode_test_8
(testing "encode -> encode all the letters"
(testing "encode all the letters"
(is (= "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
(atbash-cipher/encode "The quick brown fox jumps over the lazy dog.")))))

(deftest decode_test_1
(testing "decode -> decode exercism"
(testing "decode exercism"
(is (= "exercism"
(atbash-cipher/decode "vcvix rhn")))))

(deftest decode_test_2
(testing "decode -> decode a sentence"
(testing "decode a sentence"
(is (= "anobstacleisoftenasteppingstone"
(atbash-cipher/decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v")))))

(deftest decode_test_3
(testing "decode -> decode numbers"
(testing "decode numbers"
(is (= "testing123testing"
(atbash-cipher/decode "gvhgr mt123 gvhgr mt")))))

(deftest decode_test_4
(testing "decode -> decode all the letters"
(testing "decode all the letters"
(is (= "thequickbrownfoxjumpsoverthelazydog"
(atbash-cipher/decode "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt")))))

0 comments on commit 7da2aec

Please sign in to comment.