|
@@ -1,5 +1,8 @@
|
|
1
|
+import org.junit.Assert;
|
1
|
2
|
import org.junit.Test;
|
2
|
3
|
|
|
4
|
+import java.io.File;
|
|
5
|
+
|
3
|
6
|
import static org.junit.Assert.*;
|
4
|
7
|
|
5
|
8
|
public class ROT13Test {
|
|
@@ -61,8 +64,11 @@ public class ROT13Test {
|
61
|
64
|
|
62
|
65
|
// When
|
63
|
66
|
String actual = cipher.encrypt(Q1);
|
|
67
|
+ System.out.println(actual);
|
|
68
|
+
|
64
|
69
|
System.out.println(Q1);
|
65
|
70
|
System.out.println(A1);
|
|
71
|
+ // System.out.println(actual);
|
66
|
72
|
// Then
|
67
|
73
|
assertTrue(actual.equals(A1));
|
68
|
74
|
|
|
@@ -70,6 +76,7 @@ public class ROT13Test {
|
70
|
76
|
String actual2 = cipher.decrypt(Q2);
|
71
|
77
|
System.out.println(Q2);
|
72
|
78
|
System.out.println(A2);
|
|
79
|
+ System.out.println(actual2);
|
73
|
80
|
// Then
|
74
|
81
|
assertTrue(actual2.equals(A2));
|
75
|
82
|
}
|
|
@@ -87,5 +94,28 @@ public class ROT13Test {
|
87
|
94
|
// Then
|
88
|
95
|
assertTrue(actual.equals(Q1));
|
89
|
96
|
}
|
90
|
|
-
|
|
97
|
+ @Test
|
|
98
|
+ public void textEncryptFile(){
|
|
99
|
+ //Given
|
|
100
|
+ File file = new File("sonnet18.txt");
|
|
101
|
+ //When
|
|
102
|
+ String expected = ROT13.encrypt("Shall I compare thee to a summer’s day?\n" +
|
|
103
|
+ "Thou art more lovely and more temperate:\n" +
|
|
104
|
+ "Rough winds do shake the darling buds of May,\n" +
|
|
105
|
+ "And summer’s lease hath all too short a date;\n" +
|
|
106
|
+ "Sometime too hot the eye of heaven shines,\n" +
|
|
107
|
+ "And often is his gold complexion dimm'd;\n" +
|
|
108
|
+ "And every fair from fair sometime declines,\n" +
|
|
109
|
+ "By chance or nature’s changing course untrimm'd;\n" +
|
|
110
|
+ "But thy eternal summer shall not fade,\n" +
|
|
111
|
+ "Nor lose possession of that fair thou ow’st;\n" +
|
|
112
|
+ "Nor shall death brag thou wander’st in his shade,\n" +
|
|
113
|
+ "When in eternal lines to time thou grow’st:\n" +
|
|
114
|
+ "So long as men can breathe or eyes can see,\n" +
|
|
115
|
+ "So long lives this, and this gives life to thee.");
|
|
116
|
+
|
|
117
|
+ String actual = ROT13.textFile("sonnet18.txt");
|
|
118
|
+ //Then
|
|
119
|
+ Assert.assertEquals(expected,actual);
|
|
120
|
+ }
|
91
|
121
|
}
|