Ensure tests don't have multiple imports (the base runtests file already imports ClassicalCiphers)

This commit is contained in:
Jake W. Ireland
2021-01-13 02:04:01 +13:00
parent 40feeb4844
commit e23f905f3e
11 changed files with 29 additions and 36 deletions

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
# docs examples
@test encrypt_affine("Hello, World!", 3, 4) == "ZQLLU, SUDLN!"
@@ -19,4 +16,4 @@ using Test
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb") == ("defendtheeastwallofthecastle", (5, 7))
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", mult=5) == ("defendtheeastwallofthecastle", (5, 7))
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", add=7) == ("defendtheeastwallofthecastle", (5, 7))
@test crack_affine("wbgbuwyqbbhtynhkkzgyqbrhtykb", add=7) == ("defendtheeastwallofthecastle", (5, 7))

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
@test encrypt_caesar("This code was not strictly invented by Julius Caesar, but it was reported by Roman historian Suetonius that Caesar used it, and hence the cipher was named.", 3) == "WKLV FRGH ZDV QRW VWULFWOB LQYHQWHG EB MXOLXV FDHVDU, EXW LW ZDV UHSRUWHG EB URPDQ KLVWRULDQ VXHWRQLXV WKDW FDHVDU XVHG LW, DQG KHQFH WKH FLSKHU ZDV QDPHG."
@test encrypt_caesar("The Caesar cipher was traditionally used by shifting each letter exactly three positions down.") == "WKH FDHVDU FLSKHU ZDV WUDGLWLRQDOOB XVHG EB VKLIWLQJ HDFK OHWWHU HADFWOB WKUHH SRVLWLRQV GRZQ."

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
@test (encrypt_enigma("AAA", [1,2,3], "AAA") == "BDZ")
@test (decrypt_enigma("BDZ", [1,2,3], "AAA") == "aaa")

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
# Wikipedia examples
@test encrypt_hill("help!", [3 3; 2 5]) == "HIAT"
@@ -25,4 +22,4 @@ using Test
@test encrypt_hill("att", [2 4 5; 9 2 1; 3 17 7]) == "PFO"
@test encrypt_hill("the gold is buried in orono", [5 17; 4 15]) == uppercase("gzscxnvcdjzxeovcrclsrc")
@test decrypt_hill("gzscxnvcdjzxeovcrclsrc", [5 17; 4 15]) == "thegoldisburiedinorono"
@test decrypt_hill("gzscxnvcdjzxeovcrclsrc", [5 17; 4 15]) == "thegoldisburiedinorono"

View File

@@ -1,5 +1,4 @@
using ClassicalCiphers
using Test
# Patrick's tests:
@test encrypt_monoalphabetic("aBcbD", Dict{Char, Char}('a' => '5', 'B' => '@', 'b' => 'o', 'D' => 'D')) == "5@coD"
@@ -9,4 +8,26 @@ using Test
@test decrypt_monoalphabetic("5@coD", Dict{Char, Char}('a' => '5', 'B' => '@', 'b' => 'o', 'D' => 'D')) == "aBcbD"
@test decrypt_monoalphabetic("WKLV FRGH ZDV LQYHQWHG EB MXOLXV FDHVDU", "DEFGHIJKLMNOPQRSTUVWXYZABC") == lowercase("THIS CODE WAS INVENTED BY JULIUS CAESAR")
# Jake's tests:
@test encrypt_monoalphabetic("hello this is plaintext", "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz") == "HELLO THIS IS PLAINTEXT"
@test encrypt_monoalphabetic("hello this is plaintext", "abcdefghijklmnopqrstuvwxyz") == "HELLO THIS IS PLAINTEXT"
@test encrypt_monoalphabetic("hello this is plaintext", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm") == "ITSSG ZIOL OL HSQOFZTBZ"
@test encrypt_monoalphabetic("hello this is plaintext", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz") == "PCSSI EPHL HL JSKHYECUE"
@test encrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz") == "HELLO THIS IS PLAINTEXT"
@test encrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz") != encrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm")
@test encrypt_monoalphabetic("hello this is plaintext", Dict('n' => 'y','f' => 'n','w' => 'b','d' => 'm','e' => 'c','o' => 'i','h' => 'p','y' => 'f','i' => 'h','r' => 'd','t' => 'e','s' => 'l','j' => 'q','q' => 'a','k' => 'r','a' => 'k','c' => 'v','p' => 'j','m' => 'z','z' => 't','g' => 'o','x' => 'u','u' => 'g','l' => 's','v' => 'w','b' => 'x')) == "pcssi ephl hl jskhyecue"
@test encrypt_monoalphabetic("hello this is plaintext", Dict('n' => 'f','f' => 'y','w' => 'v','d' => 'r','e' => 't','o' => 'g','h' => 'i','j' => 'p','i' => 'o','k' => 'a','r' => 'k','s' => 'l','t' => 'z','q' => 'j','y' => 'n','a' => 'q','c' => 'e','p' => 'h','m' => 'd','z' => 'm','g' => 'u','v' => 'c','l' => 's','u' => 'x','x' => 'b','b' => 'w')) == "itssg ziol ol hsqofztbz"
@test decrypt_monoalphabetic("hello this is ciphertext", "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz") == "hello this is ciphertext"
@test decrypt_monoalphabetic("hello this is ciphertext", "abcdefghijklmnopqrstuvwxyz") == "hello this is ciphertext"
@test decrypt_monoalphabetic("hello this is ciphertext", "abcdefghijklmnopqrstuvwxyz"; reverse_dict = true) == "hello this is ciphertext"
@test decrypt_monoalphabetic("hello this is ciphertext", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz") == "itssg ziol ol eohitkztbz"
@test decrypt_monoalphabetic("hello this is ciphertext", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz"; reverse_dict = false) == "pcssi ephl hl vhjpcdecue"
@test decrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm"; reverse_dict = false) == "ozllu mogs gs iljgymzwm"
@test decrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm"; reverse_dict = true) == "hello this is plaintext"
@test decrypt_monoalphabetic("PCSSI EPHL HL JSKHYECUE", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz"; reverse_dict = false) == "jvllh cjps ps qlrpfcvgc"
@test decrypt_monoalphabetic("PCSSI EPHL HL JSKHYECUE", "qwertyuiopasdfghjklzxcvbnm", "abcdefghijklmnopqrstuvwxyz"; reverse_dict = true) == "hello this is plaintext"
@test decrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm"; reverse_dict = false) != decrypt_monoalphabetic("ITSSG ZIOL OL HSQOFZTBZ", "abcdefghijklmnopqrstuvwxyz", "qwertyuiopasdfghjklzxcvbnm"; reverse_dict = true)

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
# Wikipedia example
@test encrypt_playfair("Hide the gold in the tree stump", "playfair example") == "BMODZBXDNABEKUDMUIXMMOUVIF"
@@ -23,4 +20,4 @@ using Test
@test (arr = ['P' 'L' 'A' 'Y' 'F'; 'I' 'R' 'E' 'X' 'M'; 'B' 'C' 'D' 'G' 'H'; 'K' 'N' 'O' 'Q' 'S'; 'T' 'U' 'V' 'W' 'Z'];
decrypt_playfair("DMYRANVQCRGE", arr) == "helxloworldx")
@test decrypt_playfair("GDDOGDRQARKYGDHDNKPRDAMSOGUPGKICQY", "charles") == "meetmeathamxmersmithbridgetonightx"
@test decrypt_playfair("BMODZBXDNABEKUDMUIXMMOUVIF", "playfair example") == "hidethegoldinthetrexestump"
@test decrypt_playfair("BMODZBXDNABEKUDMUIXMMOUVIF", "playfair example") == "hidethegoldinthetrexestump"

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
@test encrypt_portas("DEFENDTHEEASTWALLOFTHECASTLE", "FORTIFICATION") == uppercase("synnjscvrnrlahutukucvryrlany")
@test decrypt_portas("synnjscvrnrlahutukucvryrlany", "FORTIFICATION") == lowercase("DEFENDTHEEASTWALLOFTHECASTLE")
@@ -9,4 +6,4 @@ using Test
# doc tests
@test decrypt_portas("URYYB, JBEYQ!", "ab") == "hello, world!"
@test encrypt_portas("Hello, World!", "ab") == "URYYB, JBEYQ!"
@test encrypt_portas("Hello, World!", "ab") == "URYYB, JBEYQ!"

View File

@@ -1,6 +1,3 @@
# using ClassicalCiphers
# using Test
@test encrypt_railfence("WE ARE DISCOVERED. FLEE AT ONCE", 3) == "WECRFACERDSOEE.LETNEAIVDEO"
@test decrypt_railfence("WECRFACERDSOEE.LETNEAIVDEO", 3) == "wearediscovered.fleeatonce"
@test encrypt_railfence("Julia is strong", 10) == "JULIAISGSNTOR"

View File

@@ -1,4 +1,4 @@
using ClassicalCiphers
include(joinpath(dirname(@__DIR__), "src", "ClassicalCiphers.jl")); using .ClassicalCiphers
using Test
tests = [
@@ -12,7 +12,6 @@ tests = [
"hill",
"solitaire",
"railfence",
"substitution"
]
println("Running tests:")

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
@test encrypt_solitaire("aaaaaaaaaaaaaaa", "") == "EXKYIZSGEHUNTIQ"
@test encrypt_solitaire("aaaaaaaaaaaaaaa", "f") == "XYIUQBMHKKJBEGY"
@test encrypt_solitaire("AAAAAAAAAAAAAAA", "fo") == "TUJYMBERLGXNDIW"

View File

@@ -1,6 +1,3 @@
using ClassicalCiphers
using Test
# doc examples
@test encrypt_vigenere("ab", [0, 1]) == "AC"
@test decrypt_vigenere("ac", [0, 1]) == "ab"
@@ -36,4 +33,4 @@ LESTCOMIQUEETLAIDLUNAGACESONBECAVECUNBRULEGUEULELAUTREMIMEENBOITANTLIN
FIRMEQUIVOLAITLEPOETEESTSEMBLABLEAUPRINCEDESNUEESQUIHANTELATEMPETEETSE
RITDELARCHERBAUDELAIREEXILESURLESOLAUMILIEUDESHUEESLEMOTPOURETAGEQUATR
EESTTRAJANSESAILESDEGEANTLEMPECHENTDEMARCHER";
crack_vigenere(singh) == ("SCUBA", lowercase(ClassicalCiphers.letters_only(singh_ans))))
crack_vigenere(singh) == ("SCUBA", lowercase(ClassicalCiphers.letters_only(singh_ans))))