Update test coverage

This commit is contained in:
2023-04-14 19:01:58 -04:00
parent bd086a2ab3
commit 575ff04ecd
8 changed files with 405 additions and 446 deletions

View File

@@ -16,23 +16,23 @@ import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare;
public class ADFGX{
private static final Logger logger = LoggerFactory.getLogger(ADFGX.class);
protected static Logger logger = LoggerFactory.getLogger(ADFGX.class);
//Internal fields
private String inputString; //The string that needs encoded/decoded
private String outputString; //The string that is output after encoding/decoding
private String squareKeyword; //The keyword used in the Polybius Square
private String keyword; //The keyword used in the Columnar cipher
private boolean preserveCapitals; //Whether to respect capitals in the output string
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
private boolean preserveSymbols; //Whether to respect symbols in the output string
protected String inputString; //The string that needs encoded/decoded
protected String outputString; //The string that is output after encoding/decoding
protected String squareKeyword; //The keyword used in the Polybius Square
protected String keyword; //The keyword used in the Columnar cipher
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
//Internal ciphers
private PolybiusSquare polybiusSquare; //The first step in encoding
private Columnar columnar; //The second step in encoding
protected PolybiusSquare polybiusSquare; //The first step in encoding
protected Columnar columnar; //The second step in encoding
//Ensures Polybius keyword constraints
private void setSquareKeyword(String squareKeyword) throws InvalidKeywordException{
protected void setSquareKeyword(String squareKeyword) throws InvalidKeywordException{
if(squareKeyword == null){
throw new InvalidKeywordException("Square keyword cannot be null");
}
@@ -41,7 +41,7 @@ public class ADFGX{
this.squareKeyword = squareKeyword;
}
//Ensures Columnar keyword constraints
private void setKeyword(String keyword) throws InvalidKeywordException{
protected void setKeyword(String keyword) throws InvalidKeywordException{
if(keyword == null){
throw new InvalidKeywordException("Keyword cannot be null");
}
@@ -50,7 +50,7 @@ public class ADFGX{
this.keyword = keyword;
}
//Ensures inputString constraints
private void setInputString(String inputString) throws InvalidInputException{
protected void setInputString(String inputString) throws InvalidInputException{
if(inputString == null){
throw new InvalidInputException("Input cannot be null");
}
@@ -80,7 +80,7 @@ public class ADFGX{
logger.debug("cleaned input string '{}'", inputString);
}
//Format the output string with capitals, symbols, and numbers that are in the input string
private void formatOutputStringEncode(){
protected void formatOutputStringEncode(){
logger.debug("Formatting output string to match input string");
StringBuilder output = new StringBuilder();
@@ -109,7 +109,7 @@ public class ADFGX{
logger.debug("Saving output string '{}'", outputString);
outputString = output.toString();
}
private void formatOutputStringDecode(){
protected void formatOutputStringDecode(){
logger.debug("Formatting output string to match input string");
StringBuilder output = new StringBuilder();
int outputLocation = 0;
@@ -139,7 +139,7 @@ public class ADFGX{
outputString = output.toString();
}
//Encodes the inputString and stores the result in outputString
private void encode() throws InvalidCharacterException, InvalidInputException, InvalidKeywordException{
protected void encode() throws InvalidCharacterException, InvalidInputException, InvalidKeywordException{
//Encode the input with polybius
logger.debug("Encoding using Polybius Square");
String polybiusOutput = polybiusSquare.encode(squareKeyword, inputString);
@@ -158,7 +158,7 @@ public class ADFGX{
formatOutputStringEncode();
}
//Decodes the inputString and stores the result in outputString
private void decode() throws InvalidKeywordException, InvalidCharacterException, InvalidInputException{
protected void decode() throws InvalidKeywordException, InvalidCharacterException, InvalidInputException{
//Decode the input with columnar
logger.debug("Decoding using columnar");
String columnarOutput = columnar.decode(keyword, inputString);