Skip to content

Commit 2d7ca51

Browse files
Add displayname annotations #2971 (#3029)
* add displayname annotations to saddle-points * add displayname annotations to satellite * add displayname annotations to say * add displayname annotations to scrabble-score * add displayname annotations to secret-handshake * add displayname annotations to series * add displayname annotations to sgf-parsing * add displayname annotations to sieve * add displayname annotations to simple-cipher * add displayname annotations to space-age * add displayname annotations to spiral-matrix * add displayname annotations to state-of-tic-tac-toe * add displayname annotations to saddle-points * add displayname annotations to satellite * add displayname annotations to say * add displayname annotations to scrabble-score * add displayname annotations to secret-handshake * add displayname annotations to series * add displayname annotations to sgf-parsing * add displayname annotations to sieve * add displayname annotations to simple-cipher * add displayname annotations to space-age * add displayname annotations to spiral-matrix * add displayname annotations to state-of-tic-tac-toe * simple-cipher * say * Update exercises/practice/simple-cipher/src/test/java/SimpleCipherTest.java simple-cipher-changes Co-authored-by: Jagdish Prajapati <[email protected]> * Apply suggestion from @jagdish-15 * Apply suggestion from @jagdish-15 * Apply suggestion from @jagdish-15 * Remove accidently added duplicate tests * Removing leading spaces in empty lines --------- Co-authored-by: Jagdish Prajapati <[email protected]> [no important files changed]
1 parent 354ef47 commit 2d7ca51

File tree

12 files changed

+173
-1
lines changed

12 files changed

+173
-1
lines changed

exercises/practice/saddle-points/src/test/java/MatrixTest.java

Lines changed: 10 additions & 0 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 java.util.ArrayList;
@@ -12,6 +13,7 @@
1213
public class MatrixTest {
1314

1415
@Test
16+
@DisplayName("Can identify single saddle point")
1517
public void testCanIdentifySingleSaddlePoint() {
1618
Matrix matrix = new Matrix(Arrays.asList(
1719
Arrays.asList(9, 8, 7),
@@ -26,6 +28,7 @@ public void testCanIdentifySingleSaddlePoint() {
2628

2729
@Disabled("Remove to run test")
2830
@Test
31+
@DisplayName("Can identify that empty matrix has no saddle points")
2932
public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() {
3033
Matrix matrix = new Matrix(new ArrayList<>());
3134

@@ -36,6 +39,7 @@ public void testCanIdentifyThatEmptyMatrixHasNoSaddlePoints() {
3639

3740
@Disabled("Remove to run test")
3841
@Test
42+
@DisplayName("Can identify lack of saddle points when there are none")
3943
public void testCanIdentifyLackOfSaddlePointsWhenThereAreNone() {
4044
Matrix matrix = new Matrix(Arrays.asList(
4145
Arrays.asList(1, 2, 3),
@@ -50,6 +54,7 @@ public void testCanIdentifyLackOfSaddlePointsWhenThereAreNone() {
5054

5155
@Disabled("Remove to run test")
5256
@Test
57+
@DisplayName("Can identify multiple saddle points in a column")
5358
public void testCanIdentifyMultipleSaddlePointsInAColumn() {
5459
Matrix matrix = new Matrix(Arrays.asList(
5560
Arrays.asList(4, 5, 4),
@@ -68,6 +73,7 @@ public void testCanIdentifyMultipleSaddlePointsInAColumn() {
6873

6974
@Disabled("Remove to run test")
7075
@Test
76+
@DisplayName("Can identify multiple saddle points in a Row")
7177
public void testCanIdentifyMultipleSaddlePointsInARow() {
7278
Matrix matrix = new Matrix(Arrays.asList(
7379
Arrays.asList(6, 7, 8),
@@ -86,6 +92,7 @@ public void testCanIdentifyMultipleSaddlePointsInARow() {
8692

8793
@Disabled("Remove to run test")
8894
@Test
95+
@DisplayName("Can identify saddle point in bottom right corner")
8996
public void testCanIdentifySaddlePointInBottomRightCorner() {
9097
Matrix matrix = new Matrix(Arrays.asList(
9198
Arrays.asList(8, 7, 9),
@@ -100,6 +107,7 @@ public void testCanIdentifySaddlePointInBottomRightCorner() {
100107

101108
@Disabled("Remove to run test")
102109
@Test
110+
@DisplayName("Can identify saddle points in a non square matrix")
103111
public void testCanIdentifySaddlePointsInANonSquareMatrix() {
104112
Matrix matrix = new Matrix(Arrays.asList(
105113
Arrays.asList(3, 1, 3),
@@ -116,6 +124,7 @@ public void testCanIdentifySaddlePointsInANonSquareMatrix() {
116124

117125
@Disabled("Remove to run test")
118126
@Test
127+
@DisplayName("Can identify that saddle points in a single column matrix are those with the minimum value")
119128
public void testCanIdentifyThatSaddlePointsInASingleColumnMatrixAreThoseWithMinimumValue() {
120129
Matrix matrix = new Matrix(Arrays.asList(
121130
Collections.singletonList(2),
@@ -134,6 +143,7 @@ public void testCanIdentifyThatSaddlePointsInASingleColumnMatrixAreThoseWithMini
134143

135144
@Disabled("Remove to run test")
136145
@Test
146+
@DisplayName("Can identify that saddle points in a single row matrix are those with the maximum value")
137147
public void testCanIdentifyThatSaddlePointsInASingleRowMatrixAreThoseWithMaximumValue() {
138148
Matrix matrix = new Matrix(Arrays.asList(
139149
Arrays.asList(2, 5, 3, 5)

exercises/practice/satellite/src/test/java/SatelliteTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
import java.util.List;
55
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.DisplayName;
67
import org.junit.jupiter.api.Test;
78

89
public class SatelliteTest {
910
Satellite satellite = new Satellite();
1011

1112
@Test
13+
@DisplayName("Empty tree")
1214
public void emptyTree() {
1315
List<Character> preorder = List.of();
1416
List<Character> inorder = List.of();
@@ -22,6 +24,7 @@ public void emptyTree() {
2224

2325
@Disabled("Remove to run test")
2426
@Test
27+
@DisplayName("Tree with one item")
2528
public void treeWithOneItem() {
2629
List<Character> preorder = List.of('a');
2730
List<Character> inorder = List.of('a');
@@ -35,6 +38,7 @@ public void treeWithOneItem() {
3538

3639
@Disabled("Remove to run test")
3740
@Test
41+
@DisplayName("Tree with many items")
3842
public void treeWithManyItems() {
3943
List<Character> preorder = List.of('a', 'i', 'x', 'f', 'r');
4044
List<Character> inorder = List.of('i', 'a', 'f', 'x', 'r');
@@ -48,6 +52,7 @@ public void treeWithManyItems() {
4852

4953
@Disabled("Remove to run test")
5054
@Test
55+
@DisplayName("Reject traversals of different length")
5156
public void rejectTraversalsOfDifferentLengths() {
5257
List<Character> preorder = List.of('a', 'b');
5358
List<Character> inorder = List.of('b', 'a', 'r');
@@ -60,6 +65,7 @@ public void rejectTraversalsOfDifferentLengths() {
6065

6166
@Disabled("Remove to run test")
6267
@Test
68+
@DisplayName("Reject inconsistent traversals of same length")
6369
public void rejectInconsistentTraversalsOfSameLength() {
6470
List<Character> preorder = List.of('x', 'y', 'z');
6571
List<Character> inorder = List.of('a', 'b', 'c');
@@ -71,6 +77,7 @@ public void rejectInconsistentTraversalsOfSameLength() {
7177

7278
@Disabled("Remove to run test")
7379
@Test
80+
@DisplayName("Reject traversals with repeated items")
7481
public void rejectTraversalsWithRepeatedItems() {
7582
List<Character> preorder = List.of('a', 'b', 'a');
7683
List<Character> inorder = List.of('b', 'a', 'a');

exercises/practice/say/src/test/java/SayTest.java

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

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

@@ -8,102 +9,119 @@ public class SayTest {
89
private Say say = new Say();
910

1011
@Test
12+
@DisplayName("zero")
1113
public void zero() {
1214
assertThat(say.say(0)).isEqualTo("zero");
1315
}
1416

1517
@Disabled("Remove to run test")
1618
@Test
19+
@DisplayName("one")
1720
public void one() {
1821
assertThat(say.say(1)).isEqualTo("one");
1922
}
2023

2124
@Disabled("Remove to run test")
2225
@Test
26+
@DisplayName("fourteen")
2327
public void fourteen() {
2428
assertThat(say.say(14)).isEqualTo("fourteen");
2529
}
2630

2731
@Disabled("Remove to run test")
2832
@Test
33+
@DisplayName("twenty")
2934
public void twenty() {
3035
assertThat(say.say(20)).isEqualTo("twenty");
3136
}
3237

3338
@Disabled("Remove to run test")
3439
@Test
40+
@DisplayName("twenty-two")
3541
public void twentyTwo() {
3642
assertThat(say.say(22)).isEqualTo("twenty-two");
3743
}
3844

3945
@Disabled("Remove to run test")
4046
@Test
47+
@DisplayName("thirty")
4148
public void thirty() {
4249
assertThat(say.say(30)).isEqualTo("thirty");
4350
}
4451

4552
@Disabled("Remove to run test")
4653
@Test
54+
@DisplayName("ninety-nine")
4755
public void ninetyNine() {
4856
assertThat(say.say(99)).isEqualTo("ninety-nine");
4957
}
5058

5159
@Disabled("Remove to run test")
5260
@Test
61+
@DisplayName("one hundred")
5362
public void oneHundred() {
5463
assertThat(say.say(100)).isEqualTo("one hundred");
5564
}
5665

5766
@Disabled("Remove to run test")
5867
@Test
68+
@DisplayName("one hundred twenty-three")
5969
public void oneHundredTwentyThree() {
6070
assertThat(say.say(123)).isEqualTo("one hundred twenty-three");
6171
}
6272

6373
@Disabled("Remove to run test")
6474
@Test
75+
@DisplayName("two hundred")
6576
public void twoHundred() {
6677
assertThat(say.say(200)).isEqualTo("two hundred");
6778
}
6879

6980
@Disabled("Remove to run test")
7081
@Test
82+
@DisplayName("nine hundred ninety-nine")
7183
public void nineHundredNinetyNine() {
7284
assertThat(say.say(999)).isEqualTo("nine hundred ninety-nine");
7385
}
7486

7587
@Disabled("Remove to run test")
7688
@Test
89+
@DisplayName("one thousand")
7790
public void oneThousand() {
7891
assertThat(say.say(1_000)).isEqualTo("one thousand");
7992
}
8093

8194
@Disabled("Remove to run test")
8295
@Test
96+
@DisplayName("one thousand two hundred thirty-four")
8397
public void oneThousandTwoHundredThirtyFour() {
8498
assertThat(say.say(1_234)).isEqualTo("one thousand two hundred thirty-four");
8599
}
86100

87101
@Disabled("Remove to run test")
88102
@Test
103+
@DisplayName("one million")
89104
public void oneMillion() {
90105
assertThat(say.say(1_000_000)).isEqualTo("one million");
91106
}
92107

93108
@Disabled("Remove to run test")
94109
@Test
110+
@DisplayName("one million two thousand three hundred forty-five")
95111
public void oneMillionTwoThousandThreeHundredFortyFive() {
96112
assertThat(say.say(1_002_345)).isEqualTo("one million two thousand three hundred forty-five");
97113
}
98114

99115
@Disabled("Remove to run test")
100116
@Test
117+
@DisplayName("one billion")
101118
public void oneBillion() {
102119
assertThat(say.say(1_000_000_000)).isEqualTo("one billion");
103120
}
104121

105122
@Disabled("Remove to run test")
106123
@Test
124+
@DisplayName("a big number")
107125
public void nineHundredEightySevenBillionSixHundredFiftyFourThreeHundredTwentyOneThousandOneHundredTwentyThree() {
108126
assertThat(say.say(987_654_321_123L))
109127
.isEqualTo("nine hundred eighty-seven billion six hundred fifty-four million" +
@@ -112,13 +130,15 @@ public void nineHundredEightySevenBillionSixHundredFiftyFourThreeHundredTwentyOn
112130

113131
@Disabled("Remove to run test")
114132
@Test
133+
@DisplayName("numbers below zero are out of range")
115134
public void illegalNegativeNumber() {
116135
assertThatExceptionOfType(IllegalArgumentException.class)
117136
.isThrownBy(() -> say.say(-1));
118137
}
119138

120139
@Disabled("Remove to run test")
121140
@Test
141+
@DisplayName("numbers above 999,999,999,999 are out of range")
122142
public void illegalTooBigNumber() {
123143
assertThatExceptionOfType(IllegalArgumentException.class)
124144
.isThrownBy(() -> say.say(1_000_000_000_000L));

exercises/practice/scrabble-score/src/test/java/ScrabbleScoreTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,93 @@
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 ScrabbleScoreTest {
78

89
@Test
10+
@DisplayName("lowercase letter")
911
public void testALowerCaseLetter() {
1012
Scrabble scrabble = new Scrabble("a");
1113
assertThat(scrabble.getScore()).isEqualTo(1);
1214
}
1315

1416
@Disabled("Remove to run test")
1517
@Test
18+
@DisplayName("uppercase letter")
1619
public void testAUpperCaseLetter() {
1720
Scrabble scrabble = new Scrabble("A");
1821
assertThat(scrabble.getScore()).isEqualTo(1);
1922
}
2023

2124
@Disabled("Remove to run test")
2225
@Test
26+
@DisplayName("valuable letter")
2327
public void testAValuableLetter() {
2428
Scrabble scrabble = new Scrabble("f");
2529
assertThat(scrabble.getScore()).isEqualTo(4);
2630
}
2731

2832
@Disabled("Remove to run test")
2933
@Test
34+
@DisplayName("short word")
3035
public void testAShortWord() {
3136
Scrabble scrabble = new Scrabble("at");
3237
assertThat(scrabble.getScore()).isEqualTo(2);
3338
}
3439

3540
@Disabled("Remove to run test")
3641
@Test
42+
@DisplayName("short, valuable word")
3743
public void testAShortValuableWord() {
3844
Scrabble scrabble = new Scrabble("zoo");
3945
assertThat(scrabble.getScore()).isEqualTo(12);
4046
}
4147

4248
@Disabled("Remove to run test")
4349
@Test
50+
@DisplayName("medium word")
4451
public void testAMediumWord() {
4552
Scrabble scrabble = new Scrabble("street");
4653
assertThat(scrabble.getScore()).isEqualTo(6);
4754
}
4855

4956
@Disabled("Remove to run test")
5057
@Test
58+
@DisplayName("medium, valuable word")
5159
public void testAMediumValuableWord() {
5260
Scrabble scrabble = new Scrabble("quirky");
5361
assertThat(scrabble.getScore()).isEqualTo(22);
5462
}
5563

5664
@Disabled("Remove to run test")
5765
@Test
66+
@DisplayName("long, mixed-case word")
5867
public void testALongMixCaseWord() {
5968
Scrabble scrabble = new Scrabble("OxyphenButazone");
6069
assertThat(scrabble.getScore()).isEqualTo(41);
6170
}
6271

6372
@Disabled("Remove to run test")
6473
@Test
74+
@DisplayName("english-like word")
6575
public void testAEnglishLikeWord() {
6676
Scrabble scrabble = new Scrabble("pinata");
6777
assertThat(scrabble.getScore()).isEqualTo(8);
6878
}
6979

7080
@Disabled("Remove to run test")
7181
@Test
82+
@DisplayName("empty input")
7283
public void testAnEmptyInput() {
7384
Scrabble scrabble = new Scrabble("");
7485
assertThat(scrabble.getScore()).isEqualTo(0);
7586
}
7687

7788
@Disabled("Remove to run test")
7889
@Test
90+
@DisplayName("entire alphabet available")
7991
public void testEntireAlphabetAvailable() {
8092
Scrabble scrabble = new Scrabble("abcdefghijklmnopqrstuvwxyz");
8193
assertThat(scrabble.getScore()).isEqualTo(87);

0 commit comments

Comments
 (0)