aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Giovanini <gabrielg.desouza@gmail.com>2019-06-22 15:40:06 +0200
committerGabriel Giovanini <gabrielg.desouza@gmail.com>2019-06-22 15:40:06 +0200
commitddce2bd3c66a62cb96b2b7ef0602c00c586c429b (patch)
treeb5cd3261c2a65fbd131d78b2ecce2f9100a21104 /test
downloadgenpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.tar.gz
genpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.tar.bz2
genpass-ddce2bd3c66a62cb96b2b7ef0602c00c586c429b.zip
Bootstrap web site
Diffstat (limited to 'test')
-rw-r--r--test/genpass/gen_test.clj27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/genpass/gen_test.clj b/test/genpass/gen_test.clj
new file mode 100644
index 0000000..05d8994
--- /dev/null
+++ b/test/genpass/gen_test.clj
@@ -0,0 +1,27 @@
+(ns genpass.gen-test
+ (:require [clojure.test :refer :all]
+ [genpass.gen :refer :all]))
+
+(def valid-char-regex #"^[a-zA-Z0-1\!\@\#\%\^\&\*\(\)\{\}\[\]\-\+\=\~]*$")
+(def not-nil? (complement nil?))
+
+(deftest rand-char-test
+ (testing "check if return a valid char"
+ (is (some (partial = (rand-char)) all-char))
+ (is (some (partial = (rand-char)) all-char))
+ (is (some (partial = (rand-char)) all-char))))
+
+(deftest genpwd-test
+ (testing "check it return 12 chars by defaul"
+ (is (= 12 (count (genpwd)))))
+ (testing "check it return x chars"
+ (is (= 12 (count (genpwd 12))))
+ (is (= 0 (count (genpwd 0))))
+ (is (= 1 (count (genpwd 1))))
+ (is (= 1000 (count (genpwd 1000)))))
+ (testing "check if generate valid chars"
+ (is (not-nil? (re-matches valid-char-regex (genpwd))))
+ (is (not-nil? (re-matches valid-char-regex (genpwd 1))))
+ (is (not-nil? (re-matches valid-char-regex (genpwd 1000))))
+ (is (not-nil? (re-matches valid-char-regex (genpwd 4))))
+ )) \ No newline at end of file