Skip to content

Commit dfba4ad

Browse files
Add displayname annotations (#3003)
* Add DisplayName annotations to pov * Add DisplayName annotations to prime-factors * Add DisplayName annotations to protein-translation * Add DisplayName annotations to proverb * Add DisplayName annotations to pythagorean-triplet * Add DisplayName annotations to queen-attack * Add DisplayName annotations to rail-fence-cipher * Add DisplayName annotations to raindrops * Add DisplayName annotations to rational-numbers * Add DisplayName annotations to react * Add DisplayName annotations to queen-attack [no important files changed]
1 parent 988132d commit dfba4ad

File tree

10 files changed

+175
-0
lines changed

10 files changed

+175
-0
lines changed

exercises/practice/pov/src/test/java/PovTest.java

Lines changed: 15 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.List;
@@ -9,6 +10,7 @@
910
public class PovTest {
1011

1112
@Test
13+
@DisplayName("Results in the same tree if the input tree is a singleton")
1214
public void testFromPovGivenSingletonTree() {
1315
Tree tree = Tree.of("x");
1416
Tree expected = Tree.of("x");
@@ -17,6 +19,7 @@ public void testFromPovGivenSingletonTree() {
1719

1820
@Disabled("Remove to run test")
1921
@Test
22+
@DisplayName("Can reroot a tree with a parent and one sibling")
2023
public void testFromPovGivenTreeWithParentAndOneSibling() {
2124
Tree tree = Tree.of("parent",
2225
List.of(Tree.of("x"),
@@ -30,6 +33,7 @@ public void testFromPovGivenTreeWithParentAndOneSibling() {
3033

3134
@Disabled("Remove to run test")
3235
@Test
36+
@DisplayName("Can reroot a tree with a parent and many siblings")
3337
public void testFromPovGivenTreeWithParentAndManySibling() {
3438
Tree tree = Tree.of("parent",
3539
List.of(Tree.of("x"),
@@ -48,6 +52,7 @@ public void testFromPovGivenTreeWithParentAndManySibling() {
4852

4953
@Disabled("Remove to run test")
5054
@Test
55+
@DisplayName("an reroot a tree with new root deeply nested in the tree")
5156
public void testFromPovGivenTreeWithNewRootDeeplyNested() {
5257
Tree tree = Tree.of("level-0",
5358
List.of(Tree.of("level-1",
@@ -66,6 +71,7 @@ public void testFromPovGivenTreeWithNewRootDeeplyNested() {
6671

6772
@Disabled("Remove to run test")
6873
@Test
74+
@DisplayName("Moves children of the new root to same level as former parent")
6975
public void testFromPovGivenMovesChildrenOfNewRootToSameLevelAsFormerParent() {
7076
Tree tree = Tree.of("parent",
7177
List.of(Tree.of("x",
@@ -82,6 +88,7 @@ public void testFromPovGivenMovesChildrenOfNewRootToSameLevelAsFormerParent() {
8288

8389
@Disabled("Remove to run test")
8490
@Test
91+
@DisplayName("Can reroot a complex tree with cousins")
8592
public void testFromPovGivenComplexTreeWithCousins() {
8693
Tree tree = Tree.of("grandparent",
8794
List.of(Tree.of("parent",
@@ -110,6 +117,7 @@ public void testFromPovGivenComplexTreeWithCousins() {
110117

111118
@Disabled("Remove to run test")
112119
@Test
120+
@DisplayName("Errors if target does not exist in a singleton tree")
113121
public void testFromPovGivenNonExistentTargetInSingletonTree() {
114122
Tree tree = Tree.of("x");
115123
assertThatExceptionOfType(UnsupportedOperationException.class)
@@ -119,6 +127,7 @@ public void testFromPovGivenNonExistentTargetInSingletonTree() {
119127

120128
@Disabled("Remove to run test")
121129
@Test
130+
@DisplayName("Errors if target does not exist in a larger tree")
122131
public void testFromPovGivenNonExistentTargetInLargeTree() {
123132
Tree tree = Tree.of("parent",
124133
List.of(Tree.of("x",
@@ -134,6 +143,7 @@ public void testFromPovGivenNonExistentTargetInLargeTree() {
134143

135144
@Disabled("Remove to run test")
136145
@Test
146+
@DisplayName("Can find path to parent")
137147
public void testPathToCanFindPathToParent() {
138148
Tree tree = Tree.of("parent",
139149
List.of(Tree.of("x"),
@@ -158,6 +168,7 @@ public void testPathToCanFindPathToSibling() {
158168

159169
@Disabled("Remove to run test")
160170
@Test
171+
@DisplayName("Can find path to cousin")
161172
public void testPathToCanFindPathToCousin() {
162173
Tree tree = Tree.of("grandparent",
163174
List.of(Tree.of("parent",
@@ -176,6 +187,7 @@ public void testPathToCanFindPathToCousin() {
176187

177188
@Disabled("Remove to run test")
178189
@Test
190+
@DisplayName("Can find path not involving root")
179191
public void testPathToCanFindPathNotEnvolvingRoot() {
180192
Tree tree = Tree.of("grandparent",
181193
List.of(Tree.of("parent",
@@ -189,6 +201,7 @@ public void testPathToCanFindPathNotEnvolvingRoot() {
189201

190202
@Disabled("Remove to run test")
191203
@Test
204+
@DisplayName("Can find path from nodes other than x")
192205
public void testPathToCanFindPathFromNodesOtherThanX() {
193206
Tree tree = Tree.of("parent",
194207
List.of(Tree.of("a"),
@@ -202,6 +215,7 @@ public void testPathToCanFindPathFromNodesOtherThanX() {
202215

203216
@Disabled("Remove to run test")
204217
@Test
218+
@DisplayName("Errors if destination does not exist")
205219
public void testPathWhenDestinationDoesNotExist() {
206220
Tree tree = Tree.of("parent",
207221
List.of(Tree.of("x",
@@ -217,6 +231,7 @@ public void testPathWhenDestinationDoesNotExist() {
217231

218232
@Disabled("Remove to run test")
219233
@Test
234+
@DisplayName("Errors if source does not exist")
220235
public void testPathWhenSourceDoesNotExist() {
221236
Tree tree = Tree.of("parent",
222237
List.of(Tree.of("x",

exercises/practice/prime-factors/src/test/java/PrimeFactorsCalculatorTest.java

Lines changed: 13 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,72 +15,84 @@ public void setUp() {
1415
}
1516

1617
@Test
18+
@DisplayName("no factors")
1719
public void testNoFactors() {
1820
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(1L)).isEmpty();
1921
}
2022

2123
@Disabled("Remove to run test")
2224
@Test
25+
@DisplayName("prime number")
2326
public void testPrimeNumber() {
2427
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(2L)).containsExactly(2L);
2528
}
2629

2730
@Disabled("Remove to run test")
2831
@Test
32+
@DisplayName("another prime number")
2933
public void testAnotherPrimeNumber() {
3034
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(3L)).containsExactly(3L);
3135
}
3236

3337
@Disabled("Remove to run test")
3438
@Test
39+
@DisplayName("square of a prime")
3540
public void testSquareOfAPrime() {
3641
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(9L)).containsExactly(3L, 3L);
3742
}
3843

3944
@Disabled("Remove to run test")
4045
@Test
46+
@DisplayName("product of first prime")
4147
public void testProductOfFirstPrime() {
4248
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(4L)).containsExactly(2L, 2L);
4349
}
4450

4551
@Disabled("Remove to run test")
4652
@Test
53+
@DisplayName("cube of a prime")
4754
public void testCubeOfAPrime() {
4855
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(8L)).containsExactly(2L, 2L, 2L);
4956
}
5057

5158
@Disabled("Remove to run test")
5259
@Test
60+
@DisplayName("product of second prime")
5361
public void testProductOfSecondPrime() {
5462
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(625L)).containsExactly(5L, 5L, 5L, 5L);
5563
}
5664

5765
@Disabled("Remove to run test")
5866
@Test
67+
@DisplayName("product of third prime")
5968
public void testProductOfThirdPrime() {
6069
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(27L)).containsExactly(3L, 3L, 3L);
6170
}
6271

6372
@Disabled("Remove to run test")
6473
@Test
74+
@DisplayName("product of first and second prime")
6575
public void testProductOfFirstAndSecondPrime() {
6676
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(6L)).containsExactly(2L, 3L);
6777
}
6878

6979
@Disabled("Remove to run test")
7080
@Test
81+
@DisplayName("product of primes and non-primes")
7182
public void testProductOfPrimesAndNonPrimes() {
7283
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(12L)).containsExactly(2L, 2L, 3L);
7384
}
7485

7586
@Disabled("Remove to run test")
7687
@Test
88+
@DisplayName("product of primes")
7789
public void testProductOfPrimes() {
7890
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(901255L)).containsExactly(5L, 17L, 23L, 461L);
7991
}
8092

8193
@Disabled("Remove to run test")
8294
@Test
95+
@DisplayName("factors include a large prime")
8396
public void testFactorsIncludingALargePrime() {
8497
assertThat(primeFactorsCalculator.calculatePrimeFactorsOf(93819012551L)).containsExactly(11L, 9539L, 894119L);
8598
}

0 commit comments

Comments
 (0)