trackler 2.2.1.84 → 2.2.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/atbash-cipher/canonical-data.json +38 -14
- data/problem-specifications/exercises/bracket-push/canonical-data.json +44 -16
- data/problem-specifications/exercises/change/canonical-data.json +46 -24
- data/problem-specifications/exercises/collatz-conjecture/canonical-data.json +20 -8
- data/problem-specifications/exercises/connect/canonical-data.json +87 -67
- data/problem-specifications/exercises/crypto-square/canonical-data.json +23 -9
- data/problem-specifications/exercises/diamond/canonical-data.json +16 -6
- data/problem-specifications/exercises/difference-of-squares/canonical-data.json +29 -11
- data/problem-specifications/exercises/dominoes/canonical-data.json +37 -13
- data/problem-specifications/exercises/flatten-array/canonical-data.json +19 -7
- data/problem-specifications/exercises/meetup/canonical-data.json +667 -477
- data/tracks/haskell/config.json +9 -0
- data/tracks/haskell/docs/LEARNING.md +3 -3
- data/tracks/haskell/exercises/food-chain/examples/success-standard/src/FoodChain.hs +1 -1
- data/tracks/haskell/exercises/forth/examples/success-standard/src/Forth.hs +2 -2
- data/tracks/haskell/exercises/parallel-letter-frequency/examples/success-standard/src/Frequency.hs +1 -1
- data/tracks/haskell/exercises/sgf-parsing/examples/success-standard/src/Sgf.hs +1 -1
- data/tracks/haskell/exercises/twelve-days/README.md +89 -0
- data/tracks/haskell/exercises/twelve-days/examples/success-standard/package.yaml +16 -0
- data/tracks/haskell/exercises/twelve-days/examples/success-standard/src/TwelveDays.hs +36 -0
- data/tracks/haskell/exercises/twelve-days/package.yaml +20 -0
- data/tracks/haskell/exercises/twelve-days/src/TwelveDays.hs +4 -0
- data/tracks/haskell/exercises/twelve-days/stack.yaml +1 -0
- data/tracks/haskell/exercises/twelve-days/test/Tests.hs +146 -0
- data/tracks/haskell/exercises/zipper/examples/success-standard/src/Zipper.hs +3 -3
- data/tracks/java/exercises/allergies/.meta/version +2 -0
- data/tracks/java/exercises/allergies/src/test/java/AllergiesTest.java +10 -65
- data/tracks/java/exercises/anagram/.meta/version +1 -0
- data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +36 -35
- data/tracks/java/exercises/atbash-cipher/.meta/version +1 -0
- data/tracks/java/exercises/atbash-cipher/src/test/java/AtbashTest.java +3 -2
- data/tracks/java/exercises/bob/.meta/src/reference/java/Bob.java +3 -0
- data/tracks/java/exercises/bob/.meta/version +1 -0
- data/tracks/java/exercises/bob/src/test/java/BobTest.java +79 -15
- data/tracks/java/exercises/crypto-square/.meta/src/reference/java/CryptoSquare.java +62 -0
- data/tracks/java/exercises/crypto-square/.meta/version +1 -0
- data/tracks/java/exercises/crypto-square/src/test/java/CryptoSquareTest.java +28 -101
- data/tracks/java/exercises/custom-set/.meta/version +1 -1
- data/tracks/java/exercises/custom-set/src/test/java/CustomSetTest.java +8 -0
- data/tracks/java/exercises/forth/.meta/version +1 -1
- data/tracks/java/exercises/forth/src/test/java/ForthEvaluatorTest.java +52 -12
- data/tracks/java/exercises/pascals-triangle/.meta/version +1 -1
- data/tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleGeneratorTest.java +48 -0
- data/tracks/java/exercises/prime-factors/.meta/version +1 -0
- data/tracks/java/exercises/prime-factors/src/test/java/PrimeFactorsCalculatorTest.java +2 -6
- data/tracks/java/exercises/protein-translation/.meta/version +1 -1
- data/tracks/java/exercises/roman-numerals/.meta/version +1 -0
- data/tracks/java/exercises/roman-numerals/src/test/java/RomanNumeralsTest.java +0 -1
- data/tracks/java/exercises/rotational-cipher/.meta/version +1 -0
- data/tracks/java/exercises/rotational-cipher/src/test/java/RotationalCipherTest.java +7 -7
- data/tracks/javascript/.eslintignore +0 -1
- data/tracks/javascript/README.md +1 -1
- data/tracks/javascript/exercises/clock/example.js +8 -11
- metadata +18 -3
- data/tracks/java/exercises/crypto-square/.meta/src/reference/java/Crypto.java +0 -74
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.1.0
|
|
@@ -28,10 +28,9 @@ public class AnagramTest {
|
|
|
28
28
|
|
|
29
29
|
@Ignore("Remove to run test")
|
|
30
30
|
@Test
|
|
31
|
-
public void
|
|
32
|
-
Anagram detector = new Anagram("
|
|
33
|
-
|
|
34
|
-
assertThat(anagrams, hasItem("inlets"));
|
|
31
|
+
public void testDoesNotConfuseDifferentDuplicates() {
|
|
32
|
+
Anagram detector = new Anagram("galea");
|
|
33
|
+
assertTrue(detector.match(Collections.singletonList("eagle")).isEmpty());
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
@Ignore("Remove to run test")
|
|
@@ -44,17 +43,25 @@ public class AnagramTest {
|
|
|
44
43
|
|
|
45
44
|
@Ignore("Remove to run test")
|
|
46
45
|
@Test
|
|
47
|
-
public void
|
|
48
|
-
Anagram detector = new Anagram("
|
|
49
|
-
|
|
50
|
-
assertThat(anagrams, allOf(hasItem("gallery"), hasItem("largely"), hasItem("regally")));
|
|
46
|
+
public void testEliminateAnagramSubsets() {
|
|
47
|
+
Anagram detector = new Anagram("good");
|
|
48
|
+
assertTrue(detector.match(Arrays.asList("dog", "goody")).isEmpty());
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
@Ignore("Remove to run test")
|
|
54
52
|
@Test
|
|
55
|
-
public void
|
|
56
|
-
Anagram detector = new Anagram("
|
|
57
|
-
|
|
53
|
+
public void testDetectLongerAnagram() {
|
|
54
|
+
Anagram detector = new Anagram("listen");
|
|
55
|
+
List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana"));
|
|
56
|
+
assertThat(anagrams, hasItem("inlets"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Ignore("Remove to run test")
|
|
60
|
+
@Test
|
|
61
|
+
public void testDetectMultipleAnagramsForLongerWord() {
|
|
62
|
+
Anagram detector = new Anagram("allergy");
|
|
63
|
+
List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading"));
|
|
64
|
+
assertThat(anagrams, allOf(hasItem("gallery"), hasItem("regally"), hasItem("largely")));
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
@Ignore("Remove to run test")
|
|
@@ -66,20 +73,6 @@ public class AnagramTest {
|
|
|
66
73
|
assertThat(anagrams.size(), is(1));
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
@Ignore("Remove to run test")
|
|
70
|
-
@Test
|
|
71
|
-
public void testIdenticalWordRepeatedIsNotAnagram() {
|
|
72
|
-
Anagram detector = new Anagram("go");
|
|
73
|
-
assertTrue(detector.match(Collections.singletonList("go Go GO")).isEmpty());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@Ignore("Remove to run test")
|
|
77
|
-
@Test
|
|
78
|
-
public void testCapitalWordIsNotOwnAnagram() {
|
|
79
|
-
Anagram detector = new Anagram("BANANA");
|
|
80
|
-
assertTrue(detector.match(Collections.singletonList("Banana")).isEmpty());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
76
|
@Ignore("Remove to run test")
|
|
84
77
|
@Test
|
|
85
78
|
public void testEliminateAnagramsWithSameChecksum() {
|
|
@@ -89,9 +82,10 @@ public class AnagramTest {
|
|
|
89
82
|
|
|
90
83
|
@Ignore("Remove to run test")
|
|
91
84
|
@Test
|
|
92
|
-
public void
|
|
93
|
-
Anagram detector = new Anagram("
|
|
94
|
-
|
|
85
|
+
public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() {
|
|
86
|
+
Anagram detector = new Anagram("Orchestra");
|
|
87
|
+
List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes"));
|
|
88
|
+
assertThat(anagrams, hasItem("Carthorse"));
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
@Ignore("Remove to run test")
|
|
@@ -112,17 +106,16 @@ public class AnagramTest {
|
|
|
112
106
|
|
|
113
107
|
@Ignore("Remove to run test")
|
|
114
108
|
@Test
|
|
115
|
-
public void
|
|
116
|
-
Anagram detector = new Anagram("
|
|
117
|
-
|
|
118
|
-
assertThat(anagrams, hasItem("Carthorse"));
|
|
109
|
+
public void testWordIsNotItsOwnAnagram() {
|
|
110
|
+
Anagram detector = new Anagram("banana");
|
|
111
|
+
assertTrue(detector.match(Collections.singletonList("Banana")).isEmpty());
|
|
119
112
|
}
|
|
120
113
|
|
|
121
114
|
@Ignore("Remove to run test")
|
|
122
115
|
@Test
|
|
123
|
-
public void
|
|
124
|
-
Anagram detector = new Anagram("
|
|
125
|
-
assertTrue(detector.match(Collections.singletonList("
|
|
116
|
+
public void testIdenticalWordRepeatedIsNotAnagram() {
|
|
117
|
+
Anagram detector = new Anagram("go");
|
|
118
|
+
assertTrue(detector.match(Collections.singletonList("go Go GO")).isEmpty());
|
|
126
119
|
}
|
|
127
120
|
|
|
128
121
|
@Ignore("Remove to run test")
|
|
@@ -131,4 +124,12 @@ public class AnagramTest {
|
|
|
131
124
|
Anagram detector = new Anagram("tapper");
|
|
132
125
|
assertTrue(detector.match(Collections.singletonList("patter")).isEmpty());
|
|
133
126
|
}
|
|
127
|
+
|
|
128
|
+
@Ignore("Remove to run test")
|
|
129
|
+
@Test
|
|
130
|
+
public void testCapitalWordIsNotOwnAnagram() {
|
|
131
|
+
Anagram detector = new Anagram("BANANA");
|
|
132
|
+
assertTrue(detector.match(Collections.singletonList("Banana")).isEmpty());
|
|
133
|
+
}
|
|
134
|
+
|
|
134
135
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|
|
@@ -21,11 +21,12 @@ public class AtbashTest {
|
|
|
21
21
|
@Parameters(name = "{index}: expected plaintext \"{0}\" to encode to ciphertext \"{1}\".")
|
|
22
22
|
public static Collection<Object[]> data() {
|
|
23
23
|
return Arrays.asList(new Object[][]{
|
|
24
|
-
{"no", "ml"},
|
|
25
24
|
{"yes", "bvh"},
|
|
25
|
+
{"no", "ml"},
|
|
26
26
|
{"OMG", "lnt"},
|
|
27
|
+
{"O M G", "lnt"},
|
|
27
28
|
{"mindblowingly", "nrmwy oldrm tob"},
|
|
28
|
-
{"Testing,
|
|
29
|
+
{"Testing,1 2 3, testing.", "gvhgr mt123 gvhgr mt"},
|
|
29
30
|
{"Truth is fiction.", "gifgs rhurx grlm"},
|
|
30
31
|
{"The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"}
|
|
31
32
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.2.0
|
|
@@ -30,6 +30,15 @@ public class BobTest {
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
@Ignore("Remove to run test")
|
|
34
|
+
@Test
|
|
35
|
+
public void shoutingGibberish() {
|
|
36
|
+
assertEquals(
|
|
37
|
+
"Whoa, chill out!",
|
|
38
|
+
bob.hey("FCECDFCAAB")
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
@Ignore("Remove to run test")
|
|
34
43
|
@Test
|
|
35
44
|
public void askingAQuestion() {
|
|
@@ -48,6 +57,15 @@ public class BobTest {
|
|
|
48
57
|
);
|
|
49
58
|
}
|
|
50
59
|
|
|
60
|
+
@Ignore("Remove to run test")
|
|
61
|
+
@Test
|
|
62
|
+
public void askingGibberish() {
|
|
63
|
+
assertEquals(
|
|
64
|
+
"Sure.",
|
|
65
|
+
bob.hey("fffbbcbeab?")
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
51
69
|
@Ignore("Remove to run test")
|
|
52
70
|
@Test
|
|
53
71
|
public void talkingForcefully() {
|
|
@@ -69,7 +87,7 @@ public class BobTest {
|
|
|
69
87
|
@Test
|
|
70
88
|
public void forcefulQuestions() {
|
|
71
89
|
assertEquals(
|
|
72
|
-
"
|
|
90
|
+
"Calm down, I know what I'm doing!", bob.hey("WHAT THE HELL WERE YOU THINKING?")
|
|
73
91
|
);
|
|
74
92
|
}
|
|
75
93
|
|
|
@@ -107,33 +125,25 @@ public class BobTest {
|
|
|
107
125
|
|
|
108
126
|
@Ignore("Remove to run test")
|
|
109
127
|
@Test
|
|
110
|
-
public void
|
|
111
|
-
assertEquals(
|
|
112
|
-
"Whoa, chill out!", bob.hey("\u00dcML\u00c4\u00dcTS!")
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@Ignore("Remove to run test")
|
|
117
|
-
@Test
|
|
118
|
-
public void calmlySpeakingWithUmlauts() {
|
|
128
|
+
public void shoutingWithNoExclamationMark() {
|
|
119
129
|
assertEquals(
|
|
120
|
-
"
|
|
130
|
+
"Whoa, chill out!", bob.hey("I HATE YOU")
|
|
121
131
|
);
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
@Ignore("Remove to run test")
|
|
125
135
|
@Test
|
|
126
|
-
public void
|
|
136
|
+
public void statementContainingQuestionMark() {
|
|
127
137
|
assertEquals(
|
|
128
|
-
"
|
|
138
|
+
"Whatever.", bob.hey("Ending with ? means a question.")
|
|
129
139
|
);
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
@Ignore("Remove to run test")
|
|
133
143
|
@Test
|
|
134
|
-
public void
|
|
144
|
+
public void nonLettersWithQuestion() {
|
|
135
145
|
assertEquals(
|
|
136
|
-
"
|
|
146
|
+
"Sure.", bob.hey(":) ?")
|
|
137
147
|
);
|
|
138
148
|
}
|
|
139
149
|
|
|
@@ -160,4 +170,58 @@ public class BobTest {
|
|
|
160
170
|
"Fine. Be that way!", bob.hey(" ")
|
|
161
171
|
);
|
|
162
172
|
}
|
|
173
|
+
|
|
174
|
+
@Ignore("Remove to run test")
|
|
175
|
+
@Test
|
|
176
|
+
public void alternateSilence() {
|
|
177
|
+
assertEquals(
|
|
178
|
+
"Fine. Be that way!", bob.hey("\t\t\t\t\t\t\t\t\t\t")
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@Ignore("Remove to run test")
|
|
183
|
+
@Test
|
|
184
|
+
public void multipleLineQuestion() {
|
|
185
|
+
assertEquals(
|
|
186
|
+
"Whatever.",
|
|
187
|
+
bob.hey("\nDoes this cryogenic chamber make me look fat?\nno")
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@Ignore("Remove to run test")
|
|
192
|
+
@Test
|
|
193
|
+
public void startingWithWhitespace() {
|
|
194
|
+
assertEquals(
|
|
195
|
+
"Whatever.",
|
|
196
|
+
bob.hey(" hmmmmmmm...")
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@Ignore("Remove to run test")
|
|
201
|
+
@Test
|
|
202
|
+
public void endingWithWhiteSpace() {
|
|
203
|
+
assertEquals(
|
|
204
|
+
"Sure.",
|
|
205
|
+
bob.hey("Okay if like my spacebar quite a bit? ")
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@Ignore("Remove to run test")
|
|
210
|
+
@Test
|
|
211
|
+
public void otherWhiteSpace() {
|
|
212
|
+
assertEquals(
|
|
213
|
+
"Fine. Be that way!",
|
|
214
|
+
bob.hey("\n\r \t")
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@Ignore("Remove to run test")
|
|
219
|
+
@Test
|
|
220
|
+
public void nonQuestionEndingWithWhiteSpace() {
|
|
221
|
+
assertEquals(
|
|
222
|
+
"Whatever.",
|
|
223
|
+
bob.hey("This is a statement ending with whitespace ")
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
163
227
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import java.util.ArrayList;
|
|
2
|
+
import java.util.List;
|
|
3
|
+
|
|
4
|
+
class CryptoSquare {
|
|
5
|
+
|
|
6
|
+
private String ciphertext;
|
|
7
|
+
|
|
8
|
+
CryptoSquare(String plaintext) {
|
|
9
|
+
this.ciphertext = calculateCiphertext(plaintext);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
String getCiphertext() {
|
|
13
|
+
return ciphertext;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private String calculateCiphertext(String plaintext) {
|
|
17
|
+
String normalizedPlaintext = normalizeText(plaintext);
|
|
18
|
+
StringBuilder ciphertext = new StringBuilder(normalizedPlaintext.length());
|
|
19
|
+
int squareSize = calculateSquareSize(normalizedPlaintext);
|
|
20
|
+
|
|
21
|
+
for (int i = 0; i < squareSize; i++) {
|
|
22
|
+
for (String segment : getSegments(normalizedPlaintext, squareSize)) {
|
|
23
|
+
if (i < segment.length()) {
|
|
24
|
+
ciphertext.append(segment.charAt(i));
|
|
25
|
+
} else {
|
|
26
|
+
ciphertext.append(" ");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (i < squareSize - 1) {
|
|
31
|
+
ciphertext.append(" ");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ciphertext.toString();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private String normalizeText(String plaintext) {
|
|
39
|
+
return plaintext.toLowerCase().codePoints()
|
|
40
|
+
.filter(Character::isLetterOrDigit)
|
|
41
|
+
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
|
|
42
|
+
.toString();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private int calculateSquareSize(String normalizedPlaintext) {
|
|
46
|
+
return (int) Math.ceil(Math.sqrt(normalizedPlaintext.length()));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private List<String> getSegments(String normalizedPlaintext, int squareSize) {
|
|
50
|
+
List<String> segments = new ArrayList<>();
|
|
51
|
+
|
|
52
|
+
for (int i = 0; i < normalizedPlaintext.length(); i += squareSize) {
|
|
53
|
+
if (i + squareSize < normalizedPlaintext.length()) {
|
|
54
|
+
segments.add(normalizedPlaintext.substring(i, i + squareSize));
|
|
55
|
+
} else {
|
|
56
|
+
segments.add(normalizedPlaintext.substring(i));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return segments;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.0
|
|
@@ -8,138 +8,65 @@ import static org.junit.Assert.assertEquals;
|
|
|
8
8
|
|
|
9
9
|
public class CryptoSquareTest {
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
@Test
|
|
13
|
-
public void strangeCharactersAreStrippedDuringNormalization() {
|
|
14
|
-
Crypto crypto = new Crypto("s#$%^&plunk");
|
|
15
|
-
String expectedOutput = "splunk";
|
|
16
|
-
|
|
17
|
-
assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@Ignore("Remove to run test")
|
|
21
|
-
@Test
|
|
22
|
-
public void lettersAreLowerCasedDuringNormalization() {
|
|
23
|
-
Crypto crypto = new Crypto("WHOA HEY!");
|
|
24
|
-
String expectedOutput = "whoahey";
|
|
25
|
-
|
|
26
|
-
assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Ignore("Remove to run test")
|
|
30
|
-
@Test
|
|
31
|
-
public void numbersAreKeptDuringNormalization() {
|
|
32
|
-
Crypto crypto = new Crypto("1, 2, 3, GO!");
|
|
33
|
-
String expectedOutput = "123go";
|
|
34
|
-
|
|
35
|
-
assertEquals(expectedOutput, crypto.getNormalizedPlaintext());
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@Ignore("Remove to run test")
|
|
39
|
-
@Test
|
|
40
|
-
public void smallestSquareSizeIs2() {
|
|
41
|
-
Crypto crypto = new Crypto("1234");
|
|
42
|
-
int expectedOutput = 2;
|
|
43
|
-
|
|
44
|
-
assertEquals(expectedOutput, crypto.getSquareSize());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@Ignore("Remove to run test")
|
|
48
|
-
@Test
|
|
49
|
-
public void sizeOfTextWhoseLengthIsPerfectSquareIsItsSquareRoot() {
|
|
50
|
-
Crypto crypto = new Crypto("123456789");
|
|
51
|
-
int expectedOutput = 3;
|
|
52
|
-
|
|
53
|
-
assertEquals(expectedOutput, crypto.getSquareSize());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@Ignore("Remove to run test")
|
|
57
|
-
@Test
|
|
58
|
-
public void sizeOfTextWhoseLengthIsNoPerfectSquareIsNextBiggestSquareRoot() {
|
|
59
|
-
Crypto crypto = new Crypto("123456789abc");
|
|
60
|
-
int expectedOutput = 4;
|
|
61
|
-
|
|
62
|
-
assertEquals(expectedOutput, crypto.getSquareSize());
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Ignore("Remove to run test")
|
|
66
|
-
@Test
|
|
67
|
-
public void sizeIsDeterminedByNormalizedText() {
|
|
68
|
-
Crypto crypto = new Crypto("Oh hey, this is nuts!");
|
|
69
|
-
int expectedOutput = 4;
|
|
70
|
-
|
|
71
|
-
assertEquals(expectedOutput, crypto.getSquareSize());
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@Ignore("Remove to run test")
|
|
75
|
-
@Test
|
|
76
|
-
public void segmentsAreSplitBySquareSize() {
|
|
77
|
-
Crypto crypto = new Crypto("Never vex thine heart with idle woes");
|
|
78
|
-
List<String> expectedOutput = Arrays.asList(new String[]{"neverv", "exthin", "eheart", "withid", "lewoes"});
|
|
79
|
-
|
|
80
|
-
assertEquals(expectedOutput, crypto.getPlaintextSegments());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@Ignore("Remove to run test")
|
|
84
11
|
@Test
|
|
85
|
-
public void
|
|
86
|
-
|
|
87
|
-
|
|
12
|
+
public void emptyPlaintextResultsInEmptyCiphertext() {
|
|
13
|
+
CryptoSquare cryptoSquare = new CryptoSquare("");
|
|
14
|
+
String expectedOutput = "";
|
|
88
15
|
|
|
89
|
-
assertEquals(expectedOutput,
|
|
16
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
90
17
|
}
|
|
91
18
|
|
|
92
19
|
@Ignore("Remove to run test")
|
|
93
20
|
@Test
|
|
94
|
-
public void
|
|
95
|
-
|
|
96
|
-
String expectedOutput = "
|
|
21
|
+
public void lettersAreLowerCasedDuringEncryption() {
|
|
22
|
+
CryptoSquare cryptoSquare = new CryptoSquare("A");
|
|
23
|
+
String expectedOutput = "a";
|
|
97
24
|
|
|
98
|
-
assertEquals(expectedOutput,
|
|
25
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
99
26
|
}
|
|
100
27
|
|
|
101
28
|
@Ignore("Remove to run test")
|
|
102
29
|
@Test
|
|
103
|
-
public void
|
|
104
|
-
|
|
105
|
-
String expectedOutput = "
|
|
30
|
+
public void spacesAreRemovedDuringEncryption() {
|
|
31
|
+
CryptoSquare cryptoSquare = new CryptoSquare(" b ");
|
|
32
|
+
String expectedOutput = "b";
|
|
106
33
|
|
|
107
|
-
assertEquals(expectedOutput,
|
|
34
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
108
35
|
}
|
|
109
36
|
|
|
110
37
|
@Ignore("Remove to run test")
|
|
111
38
|
@Test
|
|
112
|
-
public void
|
|
113
|
-
|
|
114
|
-
String expectedOutput = "
|
|
39
|
+
public void punctuationIsRemovedDuringEncryption() {
|
|
40
|
+
CryptoSquare cryptoSquare = new CryptoSquare("@1,%!");
|
|
41
|
+
String expectedOutput = "1";
|
|
115
42
|
|
|
116
|
-
assertEquals(expectedOutput,
|
|
43
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
117
44
|
}
|
|
118
45
|
|
|
119
46
|
@Ignore("Remove to run test")
|
|
120
47
|
@Test
|
|
121
|
-
public void
|
|
122
|
-
|
|
123
|
-
String expectedOutput = "
|
|
48
|
+
public void nineCharacterPlaintextResultsInThreeChunksOfThreeCharacters() {
|
|
49
|
+
CryptoSquare cryptoSquare = new CryptoSquare("This is fun!");
|
|
50
|
+
String expectedOutput = "tsf hiu isn";
|
|
124
51
|
|
|
125
|
-
assertEquals(expectedOutput,
|
|
52
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
126
53
|
}
|
|
127
54
|
|
|
128
55
|
@Ignore("Remove to run test")
|
|
129
56
|
@Test
|
|
130
|
-
public void
|
|
131
|
-
|
|
132
|
-
String expectedOutput = "
|
|
57
|
+
public void eightCharacterPlaintextResultsInThreeChunksWithATrailingSpace() {
|
|
58
|
+
CryptoSquare cryptoSquare = new CryptoSquare("Chill out.");
|
|
59
|
+
String expectedOutput = "clu hlt io ";
|
|
133
60
|
|
|
134
|
-
assertEquals(expectedOutput,
|
|
61
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
135
62
|
}
|
|
136
63
|
|
|
137
64
|
@Ignore("Remove to run test")
|
|
138
65
|
@Test
|
|
139
|
-
public void
|
|
140
|
-
|
|
141
|
-
String expectedOutput = "
|
|
66
|
+
public void fiftyFourCharacterPlaintextResultsInSevenChunksWithTrailingSpaces() {
|
|
67
|
+
CryptoSquare cryptoSquare = new CryptoSquare("If man was meant to stay on the ground, god would have given us roots.");
|
|
68
|
+
String expectedOutput = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ";
|
|
142
69
|
|
|
143
|
-
assertEquals(expectedOutput,
|
|
70
|
+
assertEquals(expectedOutput, cryptoSquare.getCiphertext());
|
|
144
71
|
}
|
|
145
72
|
}
|