Updating tests

This commit is contained in:
2023-05-05 20:19:27 -04:00
parent b3ca4754ea
commit 9c41f10576
45 changed files with 2729 additions and 2239 deletions

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 04-18-23
//Modified: 05-04-23
package com.mattrixwv.cipherstream.monosubstitution;
@@ -16,16 +16,17 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
public class Vigenere{
protected static Logger logger = LoggerFactory.getLogger(Vigenere.class);
private static final Logger logger = LoggerFactory.getLogger(Vigenere.class);
//Fields
protected String inputString; //This is the string that needs encoded/decoded
protected String outputString; //This is the string that is output after encoding/decoding
protected String keyword; //This is the keyword that is resposible for determining the offsets that you change each character by
protected ArrayList<Integer> offset; //Holds the offsets coputed from each character in the keyword
protected boolean preserveCapitals; //Whether to respect capitals in the output string
protected boolean preserveWhitespace; //Whether to respect whitespace in the output string
protected boolean preserveSymbols; //Whether to respect symbols in the output string
//Settings
protected boolean preserveCapitals; //Persist capitals in the output string
protected boolean preserveWhitespace; //Persist whitespace in the output string
protected boolean preserveSymbols; //Persist symbols in the output string
//Uses keyword to calculate the offset for the Caesar cipher for each character
protected void setOffset(){
@@ -102,7 +103,7 @@ public class Vigenere{
}
}
//Encodes inputString and stores the result in outputString
protected String encode(){
protected void encode(){
logger.debug("Encoding");
StringBuilder output = new StringBuilder();
@@ -145,10 +146,9 @@ public class Vigenere{
//Save output
outputString = output.toString();
logger.debug("Encoded message '{}'", outputString);
return outputString;
}
//Decodes inputString and stores the result in outputString
protected String decode(){
protected void decode(){
logger.debug("Decoding");
StringBuilder output = new StringBuilder();
@@ -191,7 +191,6 @@ public class Vigenere{
//Save output
outputString = output.toString();
logger.debug("Decoded message '{}'", outputString);
return outputString;
}
@@ -210,37 +209,39 @@ public class Vigenere{
this.preserveWhitespace = preserveWhitespace;
this.preserveSymbols = preserveSymbols;
}
//Returns the current inputString
public String getInputString(){
return inputString;
}
//Returns the current outputString
public String getOutputString(){
return outputString;
}
//Returns the current keyword
public String getKeyword(){
return keyword;
}
//Returns the current offsets (Used mostly in bug fixing)
public List<Integer> getOffsets(){
return offset;
}
//Encodes input using key and returns the result
public String encode(String keyword, String inputString) throws InvalidKeywordException, InvalidInputException{
reset();
setKeyword(keyword);
setInputString(inputString);
return encode();
encode();
return outputString;
}
//Decodes input using key and returns the result
public String decode(String keyword, String inputString) throws InvalidKeywordException, InvalidInputException{
reset();
setKeyword(keyword);
setInputString(inputString);
return decode();
decode();
return outputString;
}
//Makes sure all of the variables are empty
//Getters
public String getInputString(){
return inputString;
}
public String getOutputString(){
return outputString;
}
public String getKeyword(){
return keyword;
}
public List<Integer> getOffsets(){
return offset;
}
//Makes sure all variables are empty
public void reset(){
logger.debug("Resetting fields");