From 94934a291fb79af18098fc06d70f5d7065653913 Mon Sep 17 00:00:00 2001 From: Matthew Ellison Date: Thu, 3 Mar 2022 22:24:19 +0000 Subject: [PATCH] Trifid cipher started --- .../polySubstitution/TestTrifid.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java diff --git a/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java b/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java new file mode 100644 index 0000000..3c9b373 --- /dev/null +++ b/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java @@ -0,0 +1,90 @@ +//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java +//Mattrixwv +// Created: 03-03-22 +//Modified: 03-03-22 +package com.mattrixwv.CipherStreamJava.polySubstitution; + + +import static org.junit.Assert.assertEquals; + +import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException; +import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException; +import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException; +import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException; + +import org.junit.Test; + + +public class TestTrifid{ + @Test + public void testEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{ + Trifid cipher = new Trifid(true, true, true, '+'); + + //Test lowercase encoding + String inputString = "messagetoencode"; + String keyword = "keyword"; + String correctOutput = "gqdokpdodljvflf"; + String output = cipher.encode(keyword, inputString); + assertEquals("Trifid failed lowercase encoding.", correctOutput, output); + //Test uppercase encoding + inputString = "MESSAGETOENCODE"; + keyword = "keyword"; + correctOutput = "GQDOKPDODLJVFLF"; + output = cipher.encode(keyword, inputString); + assertEquals("Trifid failed uppercase encoding.", correctOutput, output); + + //Test groupLength + inputString = "messagetoencode"; + keyword = "keyword"; + int groupLength = 3; + correctOutput = "gpjqdvdofodlklf"; + output = cipher.encode(keyword, groupLength, inputString); + assertEquals("Trifid failed groupLength encoding.", correctOutput, output); + + //Test whitespace encoding + inputString = "message to encode"; + keyword = "keyword"; + correctOutput = "gqdokpd od ljvflf"; + output = cipher.encode(keyword, inputString); + assertEquals("Trifid failed whitespace encoding.", correctOutput, output); + + //Test symbol encoding + inputString = "message*to-encode"; + keyword = "keyword"; + correctOutput = "gqdokpd*od-ljvflf"; + output = cipher.encode(keyword, inputString); + assertEquals("Trifid failed symbol encoding.", correctOutput, output); + + //Test mixed case, whitespace, symbol encoding + inputString = "Message to^encode"; + keyword = "keyword"; + correctOutput = "Gqdokpd od^ljvflf"; + output = cipher.encode(keyword, inputString); + assertEquals("Trifid failed mixed case, whitespace, symbol encoding.", correctOutput, output); + //Throw in groupLength for good measure + inputString = "Message to^encode"; + keyword = "keyword"; + groupLength = 3; + correctOutput = "Gpjqdvd of^odlklf"; + output = cipher.encode(keyword, groupLength, inputString); + assertEquals("Trifid failed mixed case, whitespace, symbol, groupLength encoding.", correctOutput, output); + } + + public void testNoCapitalEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{ + //TODO: + } + + public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{ + //TODO: + } + + public void testNoSymbolEncode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{ + //TODO: + } + + + @Test + public void testDecode() throws InvalidCharacterException, InvalidBaseException, InvalidKeywordException, InvalidInputException{ + //TODO: + } +}