Skip to content

Commit 831a50f

Browse files
authored
Merge branch 'main' into display2
2 parents a50761e + 51896fc commit 831a50f

File tree

4 files changed

+102
-4
lines changed

4 files changed

+102
-4
lines changed

exercises/practice/acronym/src/test/java/AcronymTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,77 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
56

67
public class AcronymTest {
7-
8+
89
@Test
10+
@DisplayName("basic")
911
public void basic() {
1012
assertThat(new Acronym("Portable Network Graphics").get())
1113
.isEqualTo("PNG");
1214
}
1315

1416
@Disabled("Remove to run test")
1517
@Test
18+
@DisplayName("lowercase words")
1619
public void lowercaseWords() {
1720
assertThat(new Acronym("Ruby on Rails").get())
1821
.isEqualTo("ROR");
1922
}
2023

2124
@Disabled("Remove to run test")
2225
@Test
26+
@DisplayName("punctuation")
2327
public void punctuation() {
2428
assertThat(new Acronym("First In, First Out").get())
2529
.isEqualTo("FIFO");
2630
}
2731

2832
@Disabled("Remove to run test")
2933
@Test
34+
@DisplayName("all caps word")
3035
public void nonAcronymAllCapsWord() {
3136
assertThat(new Acronym("GNU Image Manipulation Program").get())
3237
.isEqualTo("GIMP");
3338
}
3439

3540
@Disabled("Remove to run test")
3641
@Test
42+
@DisplayName("punctuation without whitespace")
3743
public void punctuationWithoutWhitespace() {
3844
assertThat(new Acronym("Complementary metal-oxide semiconductor").get())
3945
.isEqualTo("CMOS");
4046
}
4147

4248
@Disabled("Remove to run test")
4349
@Test
50+
@DisplayName("very long abbreviation")
4451
public void veryLongAbbreviation() {
4552
assertThat(new Acronym("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me").get())
4653
.isEqualTo("ROTFLSHTMDCOALM");
4754
}
4855

4956
@Disabled("Remove to run test")
5057
@Test
58+
@DisplayName("consecutive delimiters")
5159
public void consecutiveDelimiters() {
5260
assertThat(new Acronym("Something - I made up from thin air").get())
5361
.isEqualTo("SIMUFTA");
5462
}
5563

5664
@Disabled("Remove to run test")
5765
@Test
66+
@DisplayName("apostrophes")
5867
public void apostrophes() {
5968
assertThat(new Acronym("Halley's Comet").get())
6069
.isEqualTo("HC");
6170
}
6271

6372
@Disabled("Remove to run test")
6473
@Test
74+
@DisplayName("underscore emphasis")
6575
public void underscoreEmphasis() {
6676
assertThat(new Acronym("The Road _Not_ Taken").get())
6777
.isEqualTo("TRNT");

exercises/practice/affine-cipher/src/test/java/AffineCipherTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
@@ -9,58 +10,66 @@ public class AffineCipherTest {
910
private AffineCipher affineCipher = new AffineCipher();
1011

1112
@Test
13+
@DisplayName("encode yes")
1214
public void testEncodeYes() {
1315
assertThat(affineCipher.encode("yes", 5, 7)).isEqualTo("xbt");
1416
}
1517

1618
@Disabled("Remove to run test")
1719
@Test
20+
@DisplayName("encode no")
1821
public void testEncodeNo() {
1922
assertThat(affineCipher.encode("no", 15, 18)).isEqualTo("fu");
2023
}
2124

22-
2325
@Disabled("Remove to run test")
26+
@DisplayName("encode OMG")
2427
@Test
2528
public void testEncodeOMG() {
2629
assertThat(affineCipher.encode("OMG", 21, 3)).isEqualTo("lvz");
2730
}
2831

2932
@Disabled("Remove to run test")
3033
@Test
34+
@DisplayName("encode O M G")
3135
public void testEncodeO_M_G() {
3236
assertThat(affineCipher.encode("O M G", 25, 47)).isEqualTo("hjp");
3337
}
3438

3539
@Disabled("Remove to run test")
3640
@Test
41+
@DisplayName("encode mindblowingly")
3742
public void testEncodeMindBlowingly() {
3843
assertThat(affineCipher.encode("mindblowingly", 11, 15)).isEqualTo("rzcwa gnxzc dgt");
3944
}
4045

4146
@Disabled("Remove to run test")
4247
@Test
48+
@DisplayName("encode numbers")
4349
public void testEncodeNumbers() {
4450
assertThat(affineCipher.encode("Testing,1 2 3, testing.", 3, 4))
4551
.isEqualTo("jqgjc rw123 jqgjc rw");
4652
}
4753

4854
@Disabled("Remove to run test")
4955
@Test
56+
@DisplayName("encode deep thought")
5057
public void testEncodeDeepThought() {
5158
assertThat(affineCipher.encode("Truth is fiction.", 5, 17))
5259
.isEqualTo("iynia fdqfb ifje");
5360
}
5461

5562
@Disabled("Remove to run test")
5663
@Test
64+
@DisplayName("encode all the letters")
5765
public void testEncodeAllTheLetters() {
5866
assertThat(affineCipher.encode("The quick brown fox jumps over the lazy dog.", 17, 33))
5967
.isEqualTo("swxtj npvyk lruol iejdc blaxk swxmh qzglf");
6068
}
6169

6270
@Disabled("Remove to run test")
6371
@Test
72+
@DisplayName("encode with a not coprime to m")
6473
public void testEncodeThrowsMeaningfulException() {
6574
assertThatExceptionOfType(IllegalArgumentException.class)
6675
.isThrownBy(() -> affineCipher.encode("This is a test", 6, 17))
@@ -69,48 +78,55 @@ public void testEncodeThrowsMeaningfulException() {
6978

7079
@Disabled("Remove to run test")
7180
@Test
81+
@DisplayName("decode exercism")
7282
public void testDecodeExercism() {
7383
assertThat(affineCipher.decode("tytgn fjr", 3, 7))
7484
.isEqualTo("exercism");
7585
}
7686

7787
@Disabled("Remove to run test")
7888
@Test
89+
@DisplayName("decode a sentence")
7990
public void testDecodeSentence() {
8091
assertThat(affineCipher.decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16))
8192
.isEqualTo("anobstacleisoftenasteppingstone");
8293
}
8394

8495
@Disabled("Remove to run test")
8596
@Test
97+
@DisplayName("decode numbers")
8698
public void testDecodeNumbers() {
8799
assertThat(affineCipher.decode("odpoz ub123 odpoz ub", 25, 7))
88100
.isEqualTo("testing123testing");
89101
}
90102

91103
@Disabled("Remove to run test")
92104
@Test
105+
@DisplayName("decode all the letters")
93106
public void testDecodeAllTheLetters() {
94107
assertThat(affineCipher.decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33))
95108
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
96109
}
97110

98111
@Disabled("Remove to run test")
99112
@Test
113+
@DisplayName("decode with no spaces in input")
100114
public void testDecodeWithNoSpaces() {
101115
assertThat(affineCipher.decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33))
102116
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
103117
}
104118

105119
@Disabled("Remove to run test")
106120
@Test
121+
@DisplayName("decode with too many spaces")
107122
public void testDecodeWithTooManySpaces() {
108123
assertThat(affineCipher.decode("vszzm cly yd cg qdp", 15, 16))
109124
.isEqualTo("jollygreengiant");
110125
}
111126

112127
@Disabled("Remove to run test")
113128
@Test
129+
@DisplayName("decode with a not coprime to m")
114130
public void testDecodeThrowsMeaningfulException() {
115131
assertThatExceptionOfType(IllegalArgumentException.class)
116132
.isThrownBy(() -> affineCipher.decode("Test", 13, 5))

exercises/practice/all-your-base/src/test/java/BaseConverterTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
@@ -7,6 +8,7 @@
78
public class BaseConverterTest {
89

910
@Test
11+
@DisplayName("single bit one to decimal")
1012
public void testSingleBitOneToDecimal() {
1113
BaseConverter baseConverter = new BaseConverter(2, new int[]{1});
1214

@@ -16,6 +18,7 @@ public void testSingleBitOneToDecimal() {
1618

1719
@Disabled("Remove to run test")
1820
@Test
21+
@DisplayName("binary to single decimal")
1922
public void testBinaryToSingleDecimal() {
2023
BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1});
2124

@@ -25,6 +28,7 @@ public void testBinaryToSingleDecimal() {
2528

2629
@Disabled("Remove to run test")
2730
@Test
31+
@DisplayName("single decimal to binary")
2832
public void testSingleDecimalToBinary() {
2933
BaseConverter baseConverter = new BaseConverter(10, new int[]{5});
3034

@@ -34,6 +38,7 @@ public void testSingleDecimalToBinary() {
3438

3539
@Disabled("Remove to run test")
3640
@Test
41+
@DisplayName("binary to multiple decimal")
3742
public void testBinaryToMultipleDecimal() {
3843
BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
3944

@@ -43,6 +48,7 @@ public void testBinaryToMultipleDecimal() {
4348

4449
@Disabled("Remove to run test")
4550
@Test
51+
@DisplayName("decimal to binary")
4652
public void testDecimalToBinary() {
4753
BaseConverter baseConverter = new BaseConverter(10, new int[]{4, 2});
4854

@@ -52,6 +58,7 @@ public void testDecimalToBinary() {
5258

5359
@Disabled("Remove to run test")
5460
@Test
61+
@DisplayName("trinary to hexadecimal")
5562
public void testTrinaryToHexadecimal() {
5663
BaseConverter baseConverter = new BaseConverter(3, new int[]{1, 1, 2, 0});
5764

@@ -61,6 +68,7 @@ public void testTrinaryToHexadecimal() {
6168

6269
@Disabled("Remove to run test")
6370
@Test
71+
@DisplayName("hexadecimal to trinary")
6472
public void testHexadecimalToTrinary() {
6573
BaseConverter baseConverter = new BaseConverter(16, new int[]{2, 10});
6674

@@ -70,6 +78,7 @@ public void testHexadecimalToTrinary() {
7078

7179
@Disabled("Remove to run test")
7280
@Test
81+
@DisplayName("15-bit integer")
7382
public void test15BitInteger() {
7483
BaseConverter baseConverter = new BaseConverter(97, new int[]{3, 46, 60});
7584

@@ -79,6 +88,7 @@ public void test15BitInteger() {
7988

8089
@Disabled("Remove to run test")
8190
@Test
91+
@DisplayName("empty list")
8292
public void testEmptyDigits() {
8393
BaseConverter baseConverter = new BaseConverter(2, new int[]{});
8494

@@ -88,6 +98,7 @@ public void testEmptyDigits() {
8898

8999
@Disabled("Remove to run test")
90100
@Test
101+
@DisplayName("single zero")
91102
public void testSingleZero() {
92103
BaseConverter baseConverter = new BaseConverter(10, new int[]{0});
93104

@@ -97,6 +108,7 @@ public void testSingleZero() {
97108

98109
@Disabled("Remove to run test")
99110
@Test
111+
@DisplayName("multiple zeros")
100112
public void testMultipleZeros() {
101113
BaseConverter baseConverter = new BaseConverter(10, new int[]{0, 0, 0});
102114

@@ -106,6 +118,7 @@ public void testMultipleZeros() {
106118

107119
@Disabled("Remove to run test")
108120
@Test
121+
@DisplayName("leading zeros")
109122
public void testLeadingZeros() {
110123
BaseConverter baseConverter = new BaseConverter(7, new int[]{0, 6, 0});
111124

@@ -115,22 +128,25 @@ public void testLeadingZeros() {
115128

116129
@Disabled("Remove to run test")
117130
@Test
131+
@DisplayName("input base is one")
118132
public void testFirstBaseIsOne() {
119133
assertThatExceptionOfType(IllegalArgumentException.class)
120-
.isThrownBy(() -> new BaseConverter(1, new int[]{1}))
134+
.isThrownBy(() -> new BaseConverter(1, new int[]{0}))
121135
.withMessage("Bases must be at least 2.");
122136
}
123137

124138
@Disabled("Remove to run test")
125139
@Test
140+
@DisplayName("input base is zero")
126141
public void testFirstBaseIsZero() {
127142
assertThatExceptionOfType(IllegalArgumentException.class)
128-
.isThrownBy(() -> new BaseConverter(0, new int[]{1}))
143+
.isThrownBy(() -> new BaseConverter(0, new int[]{}))
129144
.withMessage("Bases must be at least 2.");
130145
}
131146

132147
@Disabled("Remove to run test")
133148
@Test
149+
@DisplayName("input base is negative")
134150
public void testFirstBaseIsNegative() {
135151
assertThatExceptionOfType(IllegalArgumentException.class)
136152
.isThrownBy(() -> new BaseConverter(-2, new int[]{1}))
@@ -139,6 +155,7 @@ public void testFirstBaseIsNegative() {
139155

140156
@Disabled("Remove to run test")
141157
@Test
158+
@DisplayName("negative digit")
142159
public void testNegativeDigit() {
143160
assertThatExceptionOfType(IllegalArgumentException.class)
144161
.isThrownBy(() -> new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0}))
@@ -147,6 +164,7 @@ public void testNegativeDigit() {
147164

148165
@Disabled("Remove to run test")
149166
@Test
167+
@DisplayName("invalid positive digit")
150168
public void testInvalidPositiveDigit() {
151169
assertThatExceptionOfType(IllegalArgumentException.class)
152170
.isThrownBy(() -> new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0}))
@@ -155,6 +173,7 @@ public void testInvalidPositiveDigit() {
155173

156174
@Disabled("Remove to run test")
157175
@Test
176+
@DisplayName("output base is one")
158177
public void testSecondBaseIsOne() {
159178
BaseConverter baseConverter =
160179
new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
@@ -166,6 +185,7 @@ public void testSecondBaseIsOne() {
166185

167186
@Disabled("Remove to run test")
168187
@Test
188+
@DisplayName("output base is zero")
169189
public void testSecondBaseIsZero() {
170190
BaseConverter baseConverter = new BaseConverter(10, new int[]{7});
171191

@@ -176,6 +196,7 @@ public void testSecondBaseIsZero() {
176196

177197
@Disabled("Remove to run test")
178198
@Test
199+
@DisplayName("output base is negative")
179200
public void testSecondBaseIsNegative() {
180201
BaseConverter baseConverter = new BaseConverter(2, new int[]{1});
181202

0 commit comments

Comments
 (0)