Update unit test coverage

This commit is contained in:
2023-04-22 10:52:16 -04:00
parent 494293c311
commit 59885b8df6
21 changed files with 2784 additions and 2005 deletions

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 07-09-22
//Modified: 04-18-23
package com.mattrixwv.cipherstream.monosubstitution;
@@ -45,7 +45,7 @@ public class Vigenere{
//Sets inputString
protected void setInputString(String inputString) throws InvalidInputException{
if(inputString == null){
throw new NullPointerException("Input cannot be null");
throw new InvalidInputException("Input cannot be null");
}
logger.debug("Original input string '{}'", inputString);
@@ -76,7 +76,7 @@ public class Vigenere{
//Sets keyword
protected void setKeyword(String keyword) throws InvalidKeywordException{
if(keyword == null){
throw new NullPointerException("Keyword cannot be null");
throw new InvalidKeywordException("Keyword cannot be null");
}
logger.debug("Original keyword '{}'", keyword);
@@ -119,12 +119,7 @@ public class Vigenere{
letter += offset.get((offsetCnt++) % offset.size());
//Make sure the character is still a letter, if not, wrap around
if(letter < 'A'){
logger.debug("Wrapping around to Z");
letter += 26;
}
else if(letter > 'Z'){
if(letter > 'Z'){
logger.debug("Wrapping around to A");
letter -= 26;
@@ -136,12 +131,7 @@ public class Vigenere{
letter += offset.get((offsetCnt++) % offset.size());
//Make sure the character is still a letter, if not, wrap around
if(letter < 'a'){
logger.debug("Wrapping around to z");
letter += 26;
}
else if(letter > 'z'){
if(letter > 'z'){
logger.debug("Wrapping around to a");
letter -= 26;
@@ -153,8 +143,8 @@ public class Vigenere{
}
//Save output
logger.debug("Encoded message '{}'", output);
outputString = output.toString();
logger.debug("Encoded message '{}'", outputString);
return outputString;
}
//Decodes inputString and stores the result in outputString
@@ -180,11 +170,6 @@ public class Vigenere{
letter += 26;
}
else if(letter > 'Z'){
logger.debug("Wrapping around to A");
letter -= 26;
}
}
else if(Character.isLowerCase(letter)){
logger.debug("Decoding lowercase");
@@ -196,21 +181,16 @@ public class Vigenere{
letter += 26;
}
else if(letter > 'z'){
logger.debug("Wrapping around to a");
letter -= 26;
}
}
//Add letter to output
logger.debug("Encoded letter {}", letter);
logger.debug("Decoded character {}", letter);
output.append(letter);
}
//Save output
logger.debug("Encoded message '{}'", output);
outputString = output.toString();
logger.debug("Decoded message '{}'", outputString);
return outputString;
}