Skip to content

Commit ed0f727

Browse files
transpose, triangle, twelve-days (#3035)
* transponse, triangle, twelve-days * Update display names for test cases * Update display names for triangle tests --------- Co-authored-by: Jagdish Prajapati <[email protected]>
1 parent c36c585 commit ed0f727

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

exercises/practice/transpose/src/test/java/TransposeTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import static org.assertj.core.api.Assertions.assertThat;
22

33
import org.junit.jupiter.api.Disabled;
4+
import org.junit.jupiter.api.DisplayName;
45
import org.junit.jupiter.api.Test;
56
import org.junit.jupiter.api.BeforeEach;
67

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

1516
@Test
17+
@DisplayName("empty string")
1618
public void emptyString() {
1719
assertThat(transpose.transpose("")).isEqualTo("");
1820
}
1921

2022
@Disabled("Remove to run test")
2123
@Test
24+
@DisplayName("two characters in a row")
2225
public void twoCharactersInARow() {
2326
assertThat(transpose.transpose("A1"))
2427
.isEqualTo(
@@ -28,6 +31,7 @@ public void twoCharactersInARow() {
2831

2932
@Disabled("Remove to run test")
3033
@Test
34+
@DisplayName("two characters in a column")
3135
public void twoCharactersInAColumn() {
3236
assertThat(
3337
transpose.transpose(
@@ -38,6 +42,7 @@ public void twoCharactersInAColumn() {
3842

3943
@Disabled("Remove to run test")
4044
@Test
45+
@DisplayName("simple")
4146
public void simple() {
4247
assertThat(
4348
transpose.transpose(
@@ -51,6 +56,7 @@ public void simple() {
5156

5257
@Disabled("Remove to run test")
5358
@Test
59+
@DisplayName("single line")
5460
public void singleLine() {
5561
assertThat(transpose.transpose("Single line."))
5662
.isEqualTo(
@@ -70,6 +76,7 @@ public void singleLine() {
7076

7177
@Disabled("Remove to run test")
7278
@Test
79+
@DisplayName("first line longer than second line")
7380
public void firstLineLongerThanSecondLine() {
7481
assertThat(
7582
transpose.transpose(
@@ -96,6 +103,7 @@ public void firstLineLongerThanSecondLine() {
96103

97104
@Disabled("Remove to run test")
98105
@Test
106+
@DisplayName("second line longer than first line")
99107
public void secondLineLongerThanFirstLine() {
100108
assertThat(
101109
transpose.transpose(
@@ -122,6 +130,7 @@ public void secondLineLongerThanFirstLine() {
122130

123131
@Disabled("Remove to run test")
124132
@Test
133+
@DisplayName("mixed line length")
125134
public void mixedLineLength() {
126135
assertThat(
127136
transpose.transpose(
@@ -151,6 +160,7 @@ public void mixedLineLength() {
151160

152161
@Disabled("Remove to run test")
153162
@Test
163+
@DisplayName("square")
154164
public void square() {
155165
assertThat(
156166
transpose.transpose(
@@ -169,6 +179,7 @@ public void square() {
169179

170180
@Disabled("Remove to run test")
171181
@Test
182+
@DisplayName("rectangle")
172183
public void rectangle() {
173184
assertThat(
174185
transpose.transpose(
@@ -189,6 +200,7 @@ public void rectangle() {
189200

190201
@Disabled("Remove to run test")
191202
@Test
203+
@DisplayName("triangle")
192204
public void triangle() {
193205
assertThat(
194206
transpose.transpose(
@@ -209,6 +221,7 @@ public void triangle() {
209221

210222
@Disabled("Remove to run test")
211223
@Test
224+
@DisplayName("jagged triangle")
212225
public void jaggedTriangle() {
213226
assertThat(
214227
transpose.transpose(

exercises/practice/triangle/src/test/java/TriangleTest.java

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

44
import org.junit.jupiter.api.Test;
55
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.DisplayName;
67

78
public class TriangleTest {
89

910
@Test
11+
@DisplayName("equilateral triangle")
1012
public void equilateralTrianglesHaveEqualSides() throws TriangleException {
1113
Triangle triangle = new Triangle(2, 2, 2);
1214

@@ -15,6 +17,7 @@ public void equilateralTrianglesHaveEqualSides() throws TriangleException {
1517

1618
@Disabled("Remove to run test")
1719
@Test
20+
@DisplayName("any side is unequal")
1821
public void trianglesWithOneUnequalSideAreNotEquilateral() throws TriangleException {
1922
Triangle triangle = new Triangle(2, 3, 2);
2023

@@ -23,6 +26,7 @@ public void trianglesWithOneUnequalSideAreNotEquilateral() throws TriangleExcept
2326

2427
@Disabled("Remove to run test")
2528
@Test
29+
@DisplayName("no sides are equal")
2630
public void trianglesWithNoEqualSidesAreNotEquilateral() throws TriangleException {
2731
Triangle triangle = new Triangle(5, 4, 6);
2832

@@ -31,12 +35,14 @@ public void trianglesWithNoEqualSidesAreNotEquilateral() throws TriangleExceptio
3135

3236
@Disabled("Remove to run test")
3337
@Test
38+
@DisplayName("all zero sides is not a triangle")
3439
public void trianglesWithNoSizeAreIllegal() {
3540
assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(0, 0, 0));
3641
}
3742

3843
@Disabled("Remove to run test")
3944
@Test
45+
@DisplayName("sides may be floats")
4046
public void verySmallTrianglesCanBeEquilateral() throws TriangleException {
4147
Triangle triangle = new Triangle(0.5, 0.5, 0.5);
4248

@@ -45,6 +51,7 @@ public void verySmallTrianglesCanBeEquilateral() throws TriangleException {
4551

4652
@Disabled("Remove to run test")
4753
@Test
54+
@DisplayName("last two sides are equal")
4855
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException {
4956
Triangle triangle = new Triangle(3, 4, 4);
5057

@@ -53,6 +60,7 @@ public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException {
5360

5461
@Disabled("Remove to run test")
5562
@Test
63+
@DisplayName("first two sides are equal")
5664
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException {
5765
Triangle triangle = new Triangle(4, 4, 3);
5866

@@ -61,6 +69,7 @@ public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException
6169

6270
@Disabled("Remove to run test")
6371
@Test
72+
@DisplayName("first and last sides are equal")
6473
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleException {
6574
Triangle triangle = new Triangle(4, 3, 4);
6675

@@ -69,6 +78,7 @@ public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleExcept
6978

7079
@Disabled("Remove to run test")
7180
@Test
81+
@DisplayName("equilateral triangles are also isosceles")
7282
public void equilateralTrianglesAreAlsoIsosceles() throws TriangleException {
7383
Triangle triangle = new Triangle(4, 4, 4);
7484

@@ -77,6 +87,7 @@ public void equilateralTrianglesAreAlsoIsosceles() throws TriangleException {
7787

7888
@Disabled("Remove to run test")
7989
@Test
90+
@DisplayName("no sides are equal")
8091
public void noSidesAreEqualCantBeIsoceles() throws TriangleException {
8192
Triangle triangle = new Triangle(2, 3, 4);
8293

@@ -85,24 +96,28 @@ public void noSidesAreEqualCantBeIsoceles() throws TriangleException {
8596

8697
@Disabled("Remove to run test")
8798
@Test
99+
@DisplayName("first triangle inequality violation")
88100
public void firstTriangleInequalityViolation() {
89101
assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(1, 1, 3));
90102
}
91103

92104
@Disabled("Remove to run test")
93105
@Test
106+
@DisplayName("second triangle inequality violation")
94107
public void secondTriangleInequalityViolation() {
95108
assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(1, 3, 1));
96109
}
97110

98111
@Disabled("Remove to run test")
99112
@Test
113+
@DisplayName("third triangle inequality violation")
100114
public void thirdTriangleInequalityViolation() {
101115
assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(3, 1, 1));
102116
}
103117

104118
@Disabled("Remove to run test")
105119
@Test
120+
@DisplayName("sides may be floats")
106121
public void verySmallTrianglesCanBeIsosceles() throws TriangleException {
107122
Triangle triangle = new Triangle(0.5, 0.4, 0.5);
108123

@@ -111,6 +126,7 @@ public void verySmallTrianglesCanBeIsosceles() throws TriangleException {
111126

112127
@Disabled("Remove to run test")
113128
@Test
129+
@DisplayName("no sides are equal")
114130
public void scaleneTrianglesHaveNoEqualSides() throws TriangleException {
115131
Triangle triangle = new Triangle(5, 4, 6);
116132

@@ -119,6 +135,7 @@ public void scaleneTrianglesHaveNoEqualSides() throws TriangleException {
119135

120136
@Disabled("Remove to run test")
121137
@Test
138+
@DisplayName("all sides are equal")
122139
public void allSidesEqualAreNotScalene() throws TriangleException {
123140
Triangle triangle = new Triangle(4, 4, 4);
124141

@@ -127,6 +144,7 @@ public void allSidesEqualAreNotScalene() throws TriangleException {
127144

128145
@Disabled("Remove to run test")
129146
@Test
147+
@DisplayName("first and second sides are equal")
130148
public void twoSidesEqualAreNotScalene() throws TriangleException {
131149
Triangle triangle = new Triangle(4, 4, 3);
132150

@@ -135,6 +153,7 @@ public void twoSidesEqualAreNotScalene() throws TriangleException {
135153

136154
@Disabled("Remove to run test")
137155
@Test
156+
@DisplayName("first and third sides are equal")
138157
public void firstAndThirdSidesAreEqualAreNotScalene() throws TriangleException {
139158
Triangle triangle = new Triangle(3, 4, 3);
140159

@@ -143,6 +162,7 @@ public void firstAndThirdSidesAreEqualAreNotScalene() throws TriangleException {
143162

144163
@Disabled("Remove to run test")
145164
@Test
165+
@DisplayName("second and third sides are equal")
146166
public void secondAndThirdSidesAreEqualAreNotScalene() throws TriangleException {
147167
Triangle triangle = new Triangle(4, 3, 3);
148168

@@ -151,12 +171,14 @@ public void secondAndThirdSidesAreEqualAreNotScalene() throws TriangleException
151171

152172
@Disabled("Remove to run test")
153173
@Test
174+
@DisplayName("may not violate triangle inequality")
154175
public void mayNotViolateTriangleInequality() {
155176
assertThatExceptionOfType(TriangleException.class).isThrownBy(() -> new Triangle(7, 3, 2));
156177
}
157178

158179
@Disabled("Remove to run test")
159180
@Test
181+
@DisplayName("sides may be floats")
160182
public void verySmallTrianglesCanBeScalene() throws TriangleException {
161183
Triangle triangle = new Triangle(0.5, 0.4, 0.6);
162184

exercises/practice/twelve-days/src/test/java/TwelveDaysTest.java

Lines changed: 16 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;
@@ -13,6 +14,7 @@ public void setup() {
1314
}
1415

1516
@Test
17+
@DisplayName("first day a partridge in a pear tree")
1618
public void testVerseOne() {
1719
String expectedVerseOne = "On the first day of Christmas my true love gave to me: " +
1820
"a Partridge in a Pear Tree.\n";
@@ -21,6 +23,7 @@ public void testVerseOne() {
2123

2224
@Disabled("Remove to run test")
2325
@Test
26+
@DisplayName("second day two turtle doves")
2427
public void testVerseTwo() {
2528
String expectedVerseTwo = "On the second day of Christmas my true love gave to me: two Turtle Doves, " +
2629
"and a Partridge in a Pear Tree.\n";
@@ -29,6 +32,7 @@ public void testVerseTwo() {
2932

3033
@Disabled("Remove to run test")
3134
@Test
35+
@DisplayName("third day three french hens")
3236
public void testVerseThree() {
3337
String expectedVerseThree = "On the third day of Christmas my true love gave to me: three French Hens, " +
3438
"two Turtle Doves, and a Partridge in a Pear Tree.\n";
@@ -37,6 +41,7 @@ public void testVerseThree() {
3741

3842
@Disabled("Remove to run test")
3943
@Test
44+
@DisplayName("fourth day four calling birds")
4045
public void testVerseFour() {
4146
String expectedVerseFour = "On the fourth day of Christmas my true love gave to me: four Calling Birds, " +
4247
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
@@ -45,6 +50,7 @@ public void testVerseFour() {
4550

4651
@Disabled("Remove to run test")
4752
@Test
53+
@DisplayName("fifth day five gold rings")
4854
public void testVerseFive() {
4955
String expectedVerseFive = "On the fifth day of Christmas my true love gave to me: five Gold Rings, " +
5056
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
@@ -53,6 +59,7 @@ public void testVerseFive() {
5359

5460
@Disabled("Remove to run test")
5561
@Test
62+
@DisplayName("sixth day six geese-a-laying")
5663
public void testVerseSix() {
5764
String expectedVerseSix = "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, " +
5865
"five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
@@ -62,6 +69,7 @@ public void testVerseSix() {
6269

6370
@Disabled("Remove to run test")
6471
@Test
72+
@DisplayName("seventh day seven swans-a-swimming")
6573
public void testVerseSeven() {
6674
String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me: " +
6775
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " +
@@ -71,6 +79,7 @@ public void testVerseSeven() {
7179

7280
@Disabled("Remove to run test")
7381
@Test
82+
@DisplayName("eighth day eight maids-a-milking")
7483
public void testVerseEight() {
7584
String expectedVerseEight = "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking," +
7685
" seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
@@ -80,6 +89,7 @@ public void testVerseEight() {
8089

8190
@Disabled("Remove to run test")
8291
@Test
92+
@DisplayName("ninth day nine ladies dancing")
8393
public void testVerseNine() {
8494
String expectedVerseNine = "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, " +
8595
"eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
@@ -89,6 +99,7 @@ public void testVerseNine() {
8999

90100
@Disabled("Remove to run test")
91101
@Test
102+
@DisplayName("tenth day ten lords-a-leaping")
92103
public void testVerseTen() {
93104
String expectedVerseTen = "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, " +
94105
"nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " +
@@ -99,6 +110,7 @@ public void testVerseTen() {
99110

100111
@Disabled("Remove to run test")
101112
@Test
113+
@DisplayName("eleventh day eleven pipers piping")
102114
public void testVerseEleven() {
103115
String expectedVerseEleven = "On the eleventh day of Christmas my true love gave to me: " +
104116
"eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
@@ -109,6 +121,7 @@ public void testVerseEleven() {
109121

110122
@Disabled("Remove to run test")
111123
@Test
124+
@DisplayName("twelfth day twelve drummers drumming")
112125
public void testVerseTwelve() {
113126
String expectedVerseTwelve = "On the twelfth day of Christmas my true love gave to me: " +
114127
"twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, " +
@@ -119,6 +132,7 @@ public void testVerseTwelve() {
119132

120133
@Disabled("Remove to run test")
121134
@Test
135+
@DisplayName("recites first three verses of the song")
122136
public void testFirstThreeVerses() {
123137
String expectedVersesOneToThree = "On the first day of Christmas my true love gave to me: " +
124138
"a Partridge in a Pear Tree.\n\n" +
@@ -131,6 +145,7 @@ public void testFirstThreeVerses() {
131145

132146
@Disabled("Remove to run test")
133147
@Test
148+
@DisplayName("recites three verses from the middle of the song")
134149
public void testFourthToSixthVerses() {
135150
String expectedVersesFourToSix = "On the fourth day of Christmas my true love gave to me: " +
136151
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" +
@@ -143,6 +158,7 @@ public void testFourthToSixthVerses() {
143158

144159
@Disabled("Remove to run test")
145160
@Test
161+
@DisplayName("recites the whole song")
146162
public void testSingWholeSong() {
147163
String expectedSong = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.\n" +
148164
"\n" +

0 commit comments

Comments
 (0)