You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.4 KiB
31 lines
1.4 KiB
(ns cipher-analytical-machine.analyzers.simple-substitution-test
|
|
(:require
|
|
[clojure.test :refer :all]
|
|
[cipher-analytical-machine.symbols.frequencies :as sf]
|
|
[cipher-analytical-machine.ciphers.simple-substitution :as ss]
|
|
[cipher-analytical-machine.analyzers.simple-substitution :refer :all])
|
|
(:gen-class))
|
|
|
|
(deftest get-possible-keys-vector-test
|
|
(testing "The vector must be ordered by symbols"
|
|
(are [possible-keys-map symbols expected-key-vector]
|
|
(= expected-key-vector (get-possible-key-vector possible-keys-map symbols))
|
|
{\a [\a \b] \b [\b \a] \c [\a \c]} "abc" [[\a \b] [\b \a] [\a \c]]
|
|
{\a [\a \b] \c [\b \a] \b [\a \c]} "abc" [[\a \b] [\a \c] [\b \a]])))
|
|
|
|
(deftest get-possible-key-vector-from-reversed-count-map-test
|
|
(testing ""
|
|
(are [reversed-count-map expected-key-vector]
|
|
(= expected-key-vector (get-possible-key-vector-from-reversed-count-map reversed-count-map))
|
|
{1 [\a \c] 2 [\b]} [[\b] [\a \c]]
|
|
{2 [\a] 1 [\b] 3 [\c]} [[\c] [\a] [\b]])))
|
|
|
|
(deftest get-possible-keys-test
|
|
(testing "The keys must be the all combinations"
|
|
(are [possible-keys-vector expected-keys]
|
|
(= expected-keys (get-possible-keys possible-keys-vector))
|
|
[[\a \b] [\f] [\a \c] [\g]] '("afag" "afcg" "bfag" "bfcg")
|
|
[[\a \b] [\a \c]] '("aa" "ac" "ba" "bc")
|
|
[[\a \b \c] [\a \c] [\b \c]] '("aab" "aac" "acb" "acc" "bab" "bac" "bcb" "bcc" "cab" "cac" "ccb" "ccc"))))
|
|
|