Added Morse code

This commit is contained in:
2021-07-28 20:57:49 -04:00
parent b9e4efa6c0
commit a6a30f38a9
2 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
//CipherStreamJava/src/main/java/mattrixwv/CipherStreamJava/TestVigenere.java
//Matthew Ellison
// Created: 07-25-21
//Modified: 07-25-21
//These are the tests for the Vigenere class
package mattrixwv.CipherStreamJava;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestMorse{
@Test
public void testDecode(){
Morse cipher = new Morse();
//Test 1
String input = "... --- ...";
String correctOutput = "SOS";
String output = cipher.decode(input);
assertEquals("Morse Decoding failed the first test", correctOutput, output);
//Test 2
input = "-- --- .-. ... . -.-. --- -.. .";
correctOutput = "MORSECODE";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the second test", correctOutput, output);
//Test 3
input = ".---- ..--- ...-- ----. ---.. --...";
correctOutput = "123987";
output = cipher.decode(input);
assertEquals("Morse Decoding failed the third test", correctOutput, output);
}
@Test
public void testEncode(){
Morse cipher = new Morse();
//Test 1
String input = "sos";
String correctOutput = "... --- ...";
String output = cipher.encode(input);
assertEquals("Morse Encoding failed the first test", correctOutput, output);
//Test 2
input = "MORSE, CODE";
correctOutput = "-- --- .-. ... . -.-. --- -.. .";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the second test", correctOutput, output);
//Test 3
input = "1.23 987";
correctOutput = ".---- ..--- ...-- ----. ---.. --...";
output = cipher.encode(input);
assertEquals("Morse Encoding failed the third test", correctOutput, output);
}
}