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
     }
15
     }
16
 
16
 
17
     private void createKey() {
17
     private void createKey() {
18
-        // create the hashmap key
19
         char[] abcArr = abc.toCharArray();
18
         char[] abcArr = abc.toCharArray();
20
         char[] cbaArr = cba.toCharArray();
19
         char[] cbaArr = cba.toCharArray();
21
 
20
 

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

1
 import org.junit.Assert;
1
 import org.junit.Assert;
2
 import org.junit.Test;
2
 import org.junit.Test;
3
 
3
 
4
-import java.io.BufferedReader;
5
-import java.io.FileNotFoundException;
4
+import java.io.BufferedReader;;
6
 import java.io.FileReader;
5
 import java.io.FileReader;
6
+import java.io.IOException;
7
 
7
 
8
-import static org.junit.Assert.*;
9
 
8
 
10
 public class AtbashCipherTest {
9
 public class AtbashCipherTest {
11
 
10
 
21
     }
20
     }
22
 
21
 
23
     @Test
22
     @Test
24
-    public void testFiles() throws FileNotFoundException {
23
+    public void testFiles() throws IOException {
25
 
24
 
26
         AtbashCipher cipher = new AtbashCipher();
25
         AtbashCipher cipher = new AtbashCipher();
27
 
26
 
32
         cipher.cipherFile(inputFile, outputTest);
31
         cipher.cipherFile(inputFile, outputTest);
33
         cipher.cipherFile(outputTest, decryptTest);
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
     }