mirror of
https://github.com/Smaug123/ClassicalCiphers.jl
synced 2025-10-08 19:08:41 +00:00
Ensure tests don't have multiple imports (the base runtests file already imports ClassicalCiphers)
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
using ClassicalCiphers
|
||||
using Test
|
||||
|
||||
# docs examples
|
||||
|
||||
@test encrypt_affine("Hello, World!", 3, 4) == "ZQLLU, SUDLN!"
|
||||
|
@@ -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."
|
||||
|
||||
|
@@ -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")
|
||||
|
||||
|
@@ -1,6 +1,3 @@
|
||||
using ClassicalCiphers
|
||||
using Test
|
||||
|
||||
# Wikipedia examples
|
||||
|
||||
@test encrypt_hill("help!", [3 3; 2 5]) == "HIAT"
|
||||
|
@@ -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"
|
||||
|
||||
@@ -10,3 +9,25 @@ using Test
|
||||
|
||||
@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)
|
||||
|
@@ -1,6 +1,3 @@
|
||||
using ClassicalCiphers
|
||||
using Test
|
||||
|
||||
# Wikipedia example
|
||||
@test encrypt_playfair("Hide the gold in the tree stump", "playfair example") == "BMODZBXDNABEKUDMUIXMMOUVIF"
|
||||
|
||||
|
@@ -1,6 +1,3 @@
|
||||
using ClassicalCiphers
|
||||
using Test
|
||||
|
||||
@test encrypt_portas("DEFENDTHEEASTWALLOFTHECASTLE", "FORTIFICATION") == uppercase("synnjscvrnrlahutukucvryrlany")
|
||||
@test decrypt_portas("synnjscvrnrlahutukucvryrlany", "FORTIFICATION") == lowercase("DEFENDTHEEASTWALLOFTHECASTLE")
|
||||
|
||||
|
@@ -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"
|
||||
|
@@ -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:")
|
||||
|
@@ -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"
|
||||
|
@@ -1,6 +1,3 @@
|
||||
using ClassicalCiphers
|
||||
using Test
|
||||
|
||||
# doc examples
|
||||
@test encrypt_vigenere("ab", [0, 1]) == "AC"
|
||||
@test decrypt_vigenere("ac", [0, 1]) == "ab"
|
||||
|
Reference in New Issue
Block a user