Compare commits
3
Commits
0.3.1
..
7f6f7c9f72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f6f7c9f72 | ||
|
|
a8368d09e6 | ||
|
|
ade86e319f |
@@ -1,34 +0,0 @@
|
|||||||
(ns cipher-analytical-machine.symbol_factories
|
|
||||||
(:require [clojure.string :as cs])
|
|
||||||
(:gen-class))
|
|
||||||
|
|
||||||
(defn lower-english-alphabet-factory
|
|
||||||
"Return the English alphabet with only lowercase letters"
|
|
||||||
[]
|
|
||||||
(reduce
|
|
||||||
(fn [acc val] (str acc (char val)))
|
|
||||||
""
|
|
||||||
(range (int \a) (inc (int \z)))))
|
|
||||||
|
|
||||||
(defn english-alphabet-factory
|
|
||||||
"Return the English alphabet with lower and upper case letters"
|
|
||||||
[]
|
|
||||||
(let [letters (lower-english-alphabet-factory)]
|
|
||||||
(str letters (cs/upper-case letters))))
|
|
||||||
|
|
||||||
(defn lower-ukrainian-alphabet-factory
|
|
||||||
"Return the Ukrainian alphabet with only lowercase letters"
|
|
||||||
[]
|
|
||||||
"абвгґдеєжзиіїйклмнопрстуфхцчшщьюя")
|
|
||||||
|
|
||||||
(defn ukrainian-alphabet-factory
|
|
||||||
"Return the Ukrainian alphabet with lower and upper case letters"
|
|
||||||
[]
|
|
||||||
(let [letters (lower-ukrainian-alphabet-factory)]
|
|
||||||
(str letters (cs/upper-case letters))))
|
|
||||||
|
|
||||||
(defn digit-set-factory
|
|
||||||
"Return digits"
|
|
||||||
[]
|
|
||||||
"0123456789")
|
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
(ns cipher-analytical-machine.symbol_fixtures
|
||||||
|
(:require [clojure.string :as cs])
|
||||||
|
(:gen-class))
|
||||||
|
|
||||||
|
(defn get-lower-ukrainian-alphabet
|
||||||
|
"Return the ukrainian alphabet for the symbols string"
|
||||||
|
[]
|
||||||
|
"абвгґдеєжзиіїйклмнопрстуфхцчшщьюя")
|
||||||
|
|
||||||
|
(defn get-ukrainian-alphabet
|
||||||
|
"Return the ukrainian alphabet for the symbols string"
|
||||||
|
[]
|
||||||
|
(let [letters (get-lower-ukrainian-alphabet)]
|
||||||
|
(str letters (cs/upper-case letters))))
|
||||||
|
|
||||||
|
(defn get-digits
|
||||||
|
"Return digits for the symbols string"
|
||||||
|
[]
|
||||||
|
"0123456789")
|
||||||
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
(ns cipher-analytical-machine.symbol-factories-test
|
|
||||||
(:require
|
|
||||||
[clojure.test :refer :all]
|
|
||||||
[cipher-analytical-machine.symbol_factories :refer :all]
|
|
||||||
))
|
|
||||||
|
|
||||||
(deftest lower-english-alphabet-factory-test
|
|
||||||
(let [symbols (lower-english-alphabet-factory)]
|
|
||||||
(testing "It must have same order"
|
|
||||||
(is (= "abcdefghijklmnopqrstuvwxyz" symbols)))
|
|
||||||
|
|
||||||
(testing "It must have 26 letters"
|
|
||||||
(is (= 26 (count symbols))))))
|
|
||||||
|
|
||||||
(deftest english-alphabet-factory-test
|
|
||||||
(let [symbols (english-alphabet-factory)]
|
|
||||||
(testing "It must have same order"
|
|
||||||
(is (= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" symbols)))
|
|
||||||
|
|
||||||
(testing "It must have 2*26 letters"
|
|
||||||
(is (= (* 2 26) (count symbols))))))
|
|
||||||
|
|
||||||
(deftest lower-ukrainian-alphabet-factory-test
|
|
||||||
(let [symbols (lower-ukrainian-alphabet-factory)]
|
|
||||||
(testing "It must have same order"
|
|
||||||
(is (= "абвгґдеєжзиіїйклмнопрстуфхцчшщьюя" symbols)))
|
|
||||||
|
|
||||||
(testing "It must have 33 letters"
|
|
||||||
(is (= 33 (count symbols))))))
|
|
||||||
|
|
||||||
(deftest ukrainian-alphabet-factory-test
|
|
||||||
(let [symbols (ukrainian-alphabet-factory)]
|
|
||||||
(testing "It must have same order"
|
|
||||||
(is (= "абвгґдеєжзиіїйклмнопрстуфхцчшщьюяАБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯ" symbols)))
|
|
||||||
|
|
||||||
(testing "It must have 2*33 letters"
|
|
||||||
(is (= (* 2 33) (count symbols))))))
|
|
||||||
|
|
||||||
(deftest digit-set-factory-test
|
|
||||||
(let [symbols (digit-set-factory)]
|
|
||||||
(testing "It must have same order"
|
|
||||||
(is (= "0123456789" symbols)))
|
|
||||||
|
|
||||||
(testing "It must have 10 digits"
|
|
||||||
(is (= 10 (count symbols))))))
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user