Browse Source

Finished with testing on Atbash Cypher

Trinh Tong 6 years ago
parent
commit
346abbc766
2 changed files with 13 additions and 7 deletions
  1. 0
    1
      src/main/java/AtbashCipher.java
  2. 13
    6
      src/test/java/AtbashCipherTest.java

+ 0
- 1
src/main/java/AtbashCipher.java View File

@@ -15,7 +15,6 @@ public class AtbashCipher{
15 15
     }
16 16
 
17 17
     private void createKey() {
18
-        // create the hashmap key
19 18
         char[] abcArr = abc.toCharArray();
20 19
         char[] cbaArr = cba.toCharArray();
21 20
 

+ 13
- 6
src/test/java/AtbashCipherTest.java View File

@@ -1,11 +1,10 @@
1 1
 import org.junit.Assert;
2 2
 import org.junit.Test;
3 3
 
4
-import java.io.BufferedReader;
5
-import java.io.FileNotFoundException;
4
+import java.io.BufferedReader;;
6 5
 import java.io.FileReader;
6
+import java.io.IOException;
7 7
 
8
-import static org.junit.Assert.*;
9 8
 
10 9
 public class AtbashCipherTest {
11 10
 
@@ -21,7 +20,7 @@ public class AtbashCipherTest {
21 20
     }
22 21
 
23 22
     @Test
24
-    public void testFiles() throws FileNotFoundException {
23
+    public void testFiles() throws IOException {
25 24
 
26 25
         AtbashCipher cipher = new AtbashCipher();
27 26
 
@@ -32,8 +31,16 @@ public class AtbashCipherTest {
32 31
         cipher.cipherFile(inputFile, outputTest);
33 32
         cipher.cipherFile(outputTest, decryptTest);
34 33
 
35
-        FileReader fReader = new FileReader(inputFile);
36
-        BufferedReader bufferedReader = new BufferedReader(fReader);
34
+        BufferedReader bROriginal = new BufferedReader(new FileReader(inputFile));
35
+        BufferedReader bRDecyphered = new BufferedReader(new FileReader(decryptTest));
36
+
37
+        String originalLine;
38
+        String decrpytLine;
39
+
40
+        while ((originalLine = bROriginal.readLine()) != null) {
41
+            decrpytLine = bRDecyphered.readLine();
42
+            Assert.assertEquals(originalLine, decrpytLine);
43
+        }
37 44
 
38 45
 
39 46
     }