Skip to content

Commit 21f79eb

Browse files
Related to #2971 display names (#3000)
* added @DisplayName to exercise rectangles * Add DisplayName annotations to rectangles * Add DisplayName annotations to relative-distance * Add DisplayName annotations to resistor-color * Add DisplayName annotations to resistor-color-duo * Add DisplayName annotations to resistor-color-trio * Add DisplayName annotations to reverse-string * Fix import ordering * Fix long display name line length issue [no important files changed]
1 parent 52808f1 commit 21f79eb

File tree

7 files changed

+70
-3
lines changed

7 files changed

+70
-3
lines changed

exercises/practice/rectangles/src/test/java/RectangleCounterTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.junit.jupiter.api.BeforeEach;
22
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
34
import org.junit.jupiter.api.Test;
45

56
import static org.assertj.core.api.Assertions.assertThat;
@@ -14,6 +15,7 @@ public void setUp() {
1415
}
1516

1617
@Test
18+
@DisplayName("no rows")
1719
public void testInputWithNoRowsContainsNoRectangles() {
1820
String[] inputGrid = new String[]{};
1921

@@ -22,6 +24,7 @@ public void testInputWithNoRowsContainsNoRectangles() {
2224

2325
@Disabled("Remove to run test")
2426
@Test
27+
@DisplayName("no columns")
2528
public void testInputWithNoColumnsContainsNoRectangles() {
2629
String[] inputGrid = new String[]{""};
2730

@@ -30,6 +33,7 @@ public void testInputWithNoColumnsContainsNoRectangles() {
3033

3134
@Disabled("Remove to run test")
3235
@Test
36+
@DisplayName("no rectangles")
3337
public void testNonTrivialInputWithNoRectangles() {
3438
String[] inputGrid = new String[]{" "};
3539

@@ -38,6 +42,7 @@ public void testNonTrivialInputWithNoRectangles() {
3842

3943
@Disabled("Remove to run test")
4044
@Test
45+
@DisplayName("one rectangle")
4146
public void testInputWithOneRectangle() {
4247
String[] inputGrid = new String[]{
4348
"+-+",
@@ -50,6 +55,7 @@ public void testInputWithOneRectangle() {
5055

5156
@Disabled("Remove to run test")
5257
@Test
58+
@DisplayName("two rectangles without shared parts")
5359
public void testInputWithTwoRectanglesWithoutSharedEdges() {
5460
String[] inputGrid = new String[]{
5561
" +-+",
@@ -64,6 +70,7 @@ public void testInputWithTwoRectanglesWithoutSharedEdges() {
6470

6571
@Disabled("Remove to run test")
6672
@Test
73+
@DisplayName("five rectangles with shared parts")
6774
public void testInputWithFiveRectanglesWithSharedEdges() {
6875
String[] inputGrid = new String[]{
6976
" +-+",
@@ -78,6 +85,7 @@ public void testInputWithFiveRectanglesWithSharedEdges() {
7885

7986
@Disabled("Remove to run test")
8087
@Test
88+
@DisplayName("rectangle of height 1 is counted")
8189
public void testThatRectangleOfHeightOneIsCounted() {
8290
String[] inputGrid = new String[]{
8391
"+--+",
@@ -89,6 +97,7 @@ public void testThatRectangleOfHeightOneIsCounted() {
8997

9098
@Disabled("Remove to run test")
9199
@Test
100+
@DisplayName("rectangle of width 1 is counted")
92101
public void testThatRectangleOfWidthOneIsCounted() {
93102
String[] inputGrid = new String[]{
94103
"++",
@@ -101,6 +110,7 @@ public void testThatRectangleOfWidthOneIsCounted() {
101110

102111
@Disabled("Remove to run test")
103112
@Test
113+
@DisplayName("1x1 square is counted")
104114
public void testThatOneByOneSquareIsCounted() {
105115
String[] inputGrid = new String[]{
106116
"++",
@@ -112,6 +122,7 @@ public void testThatOneByOneSquareIsCounted() {
112122

113123
@Disabled("Remove to run test")
114124
@Test
125+
@DisplayName("only complete rectangles are counted")
115126
public void testThatIncompleteRectanglesAreNotCounted() {
116127
String[] inputGrid = new String[]{
117128
" +-+",
@@ -126,6 +137,7 @@ public void testThatIncompleteRectanglesAreNotCounted() {
126137

127138
@Disabled("Remove to run test")
128139
@Test
140+
@DisplayName("rectangles can be of different sizes")
129141
public void testThatRectanglesOfDifferentSizesAreAllCounted() {
130142
String[] inputGrid = new String[]{
131143
"+------+----+",
@@ -140,6 +152,7 @@ public void testThatRectanglesOfDifferentSizesAreAllCounted() {
140152

141153
@Disabled("Remove to run test")
142154
@Test
155+
@DisplayName("corner is required for a rectangle to be complete")
143156
public void testThatIntersectionsWithoutCornerCharacterDoNotCountAsRectangleCorners() {
144157
String[] inputGrid = new String[]{
145158
"+------+----+",
@@ -154,6 +167,7 @@ public void testThatIntersectionsWithoutCornerCharacterDoNotCountAsRectangleCorn
154167

155168
@Disabled("Remove to run test")
156169
@Test
170+
@DisplayName("large input with many rectangles")
157171
public void testLargeInputWithManyRectangles() {
158172
String[] inputGrid = new String[]{
159173
"+---+--+----+",
@@ -171,6 +185,7 @@ public void testLargeInputWithManyRectangles() {
171185

172186
@Disabled("Remove to run test")
173187
@Test
188+
@DisplayName("rectangles must have four sides")
174189
public void testRectanglesMustHaveFourSides() {
175190
String[] inputGrid = new String[]{
176191
"+-+ +-+",

exercises/practice/relative-distance/src/test/java/RelativeDistanceTest.java

Lines changed: 11 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

@@ -12,6 +13,7 @@
1213
public class RelativeDistanceTest {
1314

1415
@Test
16+
@DisplayName("Direct parent-child relation")
1517
public void testDirectParentChildRelation() {
1618
Map<String, List<String>> familyTree = new HashMap<>() {
1719
{
@@ -26,6 +28,7 @@ public void testDirectParentChildRelation() {
2628

2729
@Disabled("Remove to run test")
2830
@Test
31+
@DisplayName("Sibling relationship")
2932
public void testSiblingRelationship() {
3033
Map<String, List<String>> familyTree = new HashMap<>() {
3134
{
@@ -39,6 +42,7 @@ public void testSiblingRelationship() {
3942

4043
@Disabled("Remove to run test")
4144
@Test
45+
@DisplayName("Two degrees of separation, grandchild")
4246
public void testTwoDegreesOfSeparationGrandchild() {
4347
Map<String, List<String>> familyTree = new HashMap<>() {
4448
{
@@ -53,6 +57,7 @@ public void testTwoDegreesOfSeparationGrandchild() {
5357

5458
@Disabled("Remove to run test")
5559
@Test
60+
@DisplayName("Unrelated individuals")
5661
public void testUnrelatedIndividuals() {
5762
Map<String, List<String>> familyTree = new HashMap<>() {
5863
{
@@ -67,6 +72,7 @@ public void testUnrelatedIndividuals() {
6772

6873
@Disabled("Remove to run test")
6974
@Test
75+
@DisplayName("Complex graph, cousins")
7076
public void testComplexGraphCousins() {
7177
Map<String, List<String>> familyTree = new HashMap<>() {
7278
{
@@ -131,6 +137,7 @@ public void testComplexGraphCousins() {
131137

132138
@Disabled("Remove to run test")
133139
@Test
140+
@DisplayName("Complex graph, no shortcut, far removed nephew")
134141
public void testComplexGraphNoShortcutFarRemovedNephew() {
135142
Map<String, List<String>> familyTree = new HashMap<>() {
136143
{
@@ -194,6 +201,10 @@ public void testComplexGraphNoShortcutFarRemovedNephew() {
194201

195202
@Disabled("Remove to run test")
196203
@Test
204+
@DisplayName(
205+
"Complex graph, some shortcuts, cross-down and cross-up, " +
206+
"cousins several times removed, with unrelated family tree"
207+
)
197208
public void testComplexGraphSomeShortcutsCrossDownAndCrossUpCousinsSeveralTimesRemovedWithUnrelatedFamilyTree() {
198209
Map<String, List<String>> familyTree = new HashMap<>() {
199210
{

exercises/practice/resistor-color-duo/src/test/java/ResistorColorDuoTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.junit.jupiter.api.BeforeEach;
2-
import org.junit.jupiter.api.Test;
32
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
45

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

@@ -13,6 +14,7 @@ public void setup() {
1314
}
1415

1516
@Test
17+
@DisplayName("Brown and black")
1618
public void testBrownAndBlack() {
1719
assertThat(
1820
resistorColorDuo.value(new String[]{"brown", "black"})
@@ -21,6 +23,7 @@ public void testBrownAndBlack() {
2123

2224
@Disabled("Remove to run test")
2325
@Test
26+
@DisplayName("Blue and grey")
2427
public void testBlueAndGrey() {
2528
assertThat(
2629
resistorColorDuo.value(new String[]{ "blue", "grey" })
@@ -29,6 +32,7 @@ public void testBlueAndGrey() {
2932

3033
@Disabled("Remove to run test")
3134
@Test
35+
@DisplayName("Yellow and violet")
3236
public void testYellowAndViolet() {
3337
assertThat(
3438
resistorColorDuo.value(new String[]{ "yellow", "violet" })
@@ -37,6 +41,7 @@ public void testYellowAndViolet() {
3741

3842
@Disabled("Remove to run test")
3943
@Test
44+
@DisplayName("Orange and orange")
4045
public void testOrangeAndOrange() {
4146
assertThat(
4247
resistorColorDuo.value(new String[]{ "orange", "orange" })
@@ -45,6 +50,7 @@ public void testOrangeAndOrange() {
4550

4651
@Disabled("Remove to run test")
4752
@Test
53+
@DisplayName("White and red")
4854
public void testWhiteAndRed() {
4955
assertThat(
5056
resistorColorDuo.value(new String[]{ "white", "red" })
@@ -53,6 +59,7 @@ public void testWhiteAndRed() {
5359

5460
@Disabled("Remove to run test")
5561
@Test
62+
@DisplayName("Black and brown, one-digit")
5663
public void testBlackAndBrownOneDigit() {
5764
assertThat(
5865
resistorColorDuo.value(new String[]{ "black", "brown" })
@@ -61,6 +68,7 @@ public void testBlackAndBrownOneDigit() {
6168

6269
@Disabled("Remove to run test")
6370
@Test
71+
@DisplayName("Ignore additional colors")
6472
public void testIgnoreAdditionalColors() {
6573
assertThat(
6674
resistorColorDuo.value(new String[]{ "green", "brown", "orange" })

exercises/practice/resistor-color-trio/src/test/java/ResistorColorTrioTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.junit.jupiter.api.BeforeEach;
2-
import org.junit.jupiter.api.Test;
32
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
45

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

@@ -13,6 +14,7 @@ public void setup() {
1314
}
1415

1516
@Test
17+
@DisplayName("Orange and orange and black")
1618
public void testOrangeAndOrangeAndBlack() {
1719
assertThat(
1820
resistorColorTrio.label(new String[]{"orange", "orange", "black"})
@@ -21,6 +23,7 @@ public void testOrangeAndOrangeAndBlack() {
2123

2224
@Disabled("Remove to run test")
2325
@Test
26+
@DisplayName("Blue and grey and brown")
2427
public void testBlueAndGreyAndBrown() {
2528
assertThat(
2629
resistorColorTrio.label(new String[]{"blue", "grey", "brown"})
@@ -29,6 +32,7 @@ public void testBlueAndGreyAndBrown() {
2932

3033
@Disabled("Remove to run test")
3134
@Test
35+
@DisplayName("Red and black and red")
3236
public void testRedAndBlackAndRed() {
3337
assertThat(
3438
resistorColorTrio.label(new String[]{"red", "black", "red"})
@@ -37,6 +41,7 @@ public void testRedAndBlackAndRed() {
3741

3842
@Disabled("Remove to run test")
3943
@Test
44+
@DisplayName("Green and brown and orange")
4045
public void testGreenAndBrownAndOrange() {
4146
assertThat(
4247
resistorColorTrio.label(new String[]{"green", "brown", "orange"})
@@ -45,6 +50,7 @@ public void testGreenAndBrownAndOrange() {
4550

4651
@Disabled("Remove to run test")
4752
@Test
53+
@DisplayName("Yellow and violet and yellow")
4854
public void testYellowAndVioletAndYellow() {
4955
assertThat(
5056
resistorColorTrio.label(new String[]{"yellow", "violet", "yellow"})
@@ -53,6 +59,7 @@ public void testYellowAndVioletAndYellow() {
5359

5460
@Disabled("Remove to run test")
5561
@Test
62+
@DisplayName("Blue and violet and blue")
5663
public void testBlueAndVioletAndBlue() {
5764
assertThat(
5865
resistorColorTrio.label(new String[]{"blue", "violet", "blue"})
@@ -61,6 +68,7 @@ public void testBlueAndVioletAndBlue() {
6168

6269
@Disabled("Remove to run test")
6370
@Test
71+
@DisplayName("Minimum possible value")
6472
public void testBlackAndBlackAndBlack() {
6573
assertThat(
6674
resistorColorTrio.label(new String[]{"black", "black", "black"})
@@ -69,6 +77,7 @@ public void testBlackAndBlackAndBlack() {
6977

7078
@Disabled("Remove to run test")
7179
@Test
80+
@DisplayName("Maximum possible value")
7281
public void testWhiteAndWhiteAndWhite() {
7382
assertThat(
7483
resistorColorTrio.label(new String[]{"white", "white", "white"})
@@ -77,6 +86,7 @@ public void testWhiteAndWhiteAndWhite() {
7786

7887
@Disabled("Remove to run test")
7988
@Test
89+
@DisplayName("First two colors make an invalid octal number")
8090
public void testFirstTwoColorsMakeAnInvalidOctalNumber() {
8191
assertThat(
8292
resistorColorTrio.label(new String[]{"black", "grey", "black"})
@@ -85,6 +95,7 @@ public void testFirstTwoColorsMakeAnInvalidOctalNumber() {
8595

8696
@Disabled("Remove to run test")
8797
@Test
98+
@DisplayName("Ignore extra colors")
8899
public void testIgnoreExtraColors() {
89100
assertThat(
90101
resistorColorTrio.label(new String[]{"blue", "green", "yellow", "orange"})

exercises/practice/resistor-color/src/test/java/ResistorColorTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import org.junit.jupiter.api.BeforeEach;
2-
import org.junit.jupiter.api.Test;
32
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
45
import static org.assertj.core.api.Assertions.assertThat;
56

67
public class ResistorColorTest {
@@ -13,24 +14,28 @@ public void setup() {
1314
}
1415

1516
@Test
17+
@DisplayName("Black")
1618
public void testBlackColorCode() {
1719
assertThat(resistorColor.colorCode("black")).isEqualTo(0);
1820
}
1921

2022
@Disabled("Remove to run test")
2123
@Test
24+
@DisplayName("white")
2225
public void testWhiteColorCode() {
2326
assertThat(resistorColor.colorCode("white")).isEqualTo(9);
2427
}
2528

2629
@Disabled("Remove to run test")
2730
@Test
31+
@DisplayName("Orange")
2832
public void testOrangeColorCode() {
2933
assertThat(resistorColor.colorCode("orange")).isEqualTo(3);
3034
}
3135

3236
@Disabled("Remove to run test")
3337
@Test
38+
@DisplayName("Colors")
3439
public void testColors() {
3540
assertThat(resistorColor.colors()).containsExactly(
3641
"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"

0 commit comments

Comments
 (0)