Skip to content

Commit 0e3dd93

Browse files
committed
dominoes, et1, flatten-array
1 parent 2dcd936 commit 0e3dd93

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

exercises/practice/dominoes/src/test/java/DominoesTest.java

Lines changed: 14 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 DominoesTest {
1314

1415
@Test
16+
@DisplayName("empty input = empty output")
1517
public void emtpyInputEmptyOutputTest() throws ChainNotFoundException {
1618
Dominoes dominoes = new Dominoes();
1719

@@ -24,6 +26,7 @@ public void emtpyInputEmptyOutputTest() throws ChainNotFoundException {
2426

2527
@Disabled("Remove to run test")
2628
@Test
29+
@DisplayName("singleton input = singleton output")
2730
public void singletonInputSingletonOutput() throws ChainNotFoundException {
2831
Dominoes dominoes = new Dominoes();
2932

@@ -37,6 +40,7 @@ public void singletonInputSingletonOutput() throws ChainNotFoundException {
3740

3841
@Disabled("Remove to run test")
3942
@Test
43+
@DisplayName("singleton that can't be chained")
4044
public void singletonCantBeChainedTest() {
4145
Dominoes dominoes = new Dominoes();
4246

@@ -50,6 +54,7 @@ public void singletonCantBeChainedTest() {
5054

5155
@Disabled("Remove to run test")
5256
@Test
57+
@DisplayName("three elements")
5358
public void threeElementsTest() throws ChainNotFoundException {
5459
Dominoes dominoes = new Dominoes();
5560

@@ -63,6 +68,7 @@ public void threeElementsTest() throws ChainNotFoundException {
6368

6469
@Disabled("Remove to run test")
6570
@Test
71+
@DisplayName("can reverse dominoes")
6672
public void canReverseDominoesTest() throws ChainNotFoundException {
6773
Dominoes dominoes = new Dominoes();
6874

@@ -76,6 +82,7 @@ public void canReverseDominoesTest() throws ChainNotFoundException {
7682

7783
@Disabled("Remove to run test")
7884
@Test
85+
@DisplayName("can't be chained")
7986
public void cantBeChainedTest() {
8087
Dominoes dominoes = new Dominoes();
8188

@@ -89,6 +96,7 @@ public void cantBeChainedTest() {
8996

9097
@Disabled("Remove to run test")
9198
@Test
99+
@DisplayName("disconnected - simple")
92100
public void disconnectedSimpleTest() {
93101
Dominoes dominoes = new Dominoes();
94102

@@ -102,6 +110,7 @@ public void disconnectedSimpleTest() {
102110

103111
@Disabled("Remove to run test")
104112
@Test
113+
@DisplayName("disconnected - double loop")
105114
public void disconnectedDoubleLoopTest() {
106115
Dominoes dominoes = new Dominoes();
107116

@@ -115,6 +124,7 @@ public void disconnectedDoubleLoopTest() {
115124

116125
@Disabled("Remove to run test")
117126
@Test
127+
@DisplayName("disconnected - single isolated")
118128
public void disconnectedSingleIsolatedTest() {
119129
Dominoes dominoes = new Dominoes();
120130

@@ -128,6 +138,7 @@ public void disconnectedSingleIsolatedTest() {
128138

129139
@Disabled("Remove to run test")
130140
@Test
141+
@DisplayName("need backtrack")
131142
public void needBacktrackTest() throws ChainNotFoundException {
132143
Dominoes dominoes = new Dominoes();
133144

@@ -142,6 +153,7 @@ public void needBacktrackTest() throws ChainNotFoundException {
142153

143154
@Disabled("Remove to run test")
144155
@Test
156+
@DisplayName("separate loops")
145157
public void separateLoopsTest() throws ChainNotFoundException {
146158
Dominoes dominoes = new Dominoes();
147159

@@ -156,6 +168,7 @@ public void separateLoopsTest() throws ChainNotFoundException {
156168

157169
@Disabled("Remove to run test")
158170
@Test
171+
@DisplayName("nine elements")
159172
public void nineElementsTest() throws ChainNotFoundException {
160173
Dominoes dominoes = new Dominoes();
161174
Domino[] dominoesArray = {new Domino(1, 2), new Domino(5, 3), new Domino(3, 1),
@@ -170,6 +183,7 @@ public void nineElementsTest() throws ChainNotFoundException {
170183

171184
@Disabled("Remove to run test")
172185
@Test
186+
@DisplayName("separate three-domino loops")
173187
public void separateThreeDominoLoopsTest() {
174188
Dominoes dominoes = new Dominoes();
175189

exercises/practice/etl/src/test/java/EtlTest.java

Lines changed: 5 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.Arrays;
@@ -14,6 +15,7 @@ public class EtlTest {
1415
private final Etl etl = new Etl();
1516

1617
@Test
18+
@DisplayName("single letter")
1719
public void testTransformOneValue() {
1820
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
1921
{
@@ -34,6 +36,7 @@ public void testTransformOneValue() {
3436

3537
@Disabled("Remove to run test")
3638
@Test
39+
@DisplayName("single score with multiple letters")
3740
public void testTransformMoreValues() {
3841
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
3942
{
@@ -58,6 +61,7 @@ public void testTransformMoreValues() {
5861

5962
@Disabled("Remove to run test")
6063
@Test
64+
@DisplayName("multiple scores with multiple letters")
6165
public void testMoreKeys() {
6266
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
6367
{
@@ -82,6 +86,7 @@ public void testMoreKeys() {
8286

8387
@Disabled("Remove to run test")
8488
@Test
89+
@DisplayName("multiple scores with differing numbers of letters")
8590
public void testFullDataset() {
8691
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
8792
{

exercises/practice/flatten-array/src/test/java/FlattenerTest.java

Lines changed: 12 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 java.util.Arrays.asList;
@@ -17,34 +18,39 @@ public void setUp() {
1718
}
1819

1920
@Test
21+
@DisplayName("empty")
2022
public void testEmpty() {
2123
assertThat(flattener.flatten(emptyList()))
2224
.isEmpty();
2325
}
2426

2527
@Disabled("Remove to run test")
2628
@Test
29+
@DisplayName("no nesting")
2730
public void testFlatListIsPreserved() {
2831
assertThat(flattener.flatten(asList(0, '1', "two")))
2932
.containsExactly(0, '1', "two");
3033
}
3134

3235
@Disabled("Remove to run test")
3336
@Test
37+
@DisplayName("flattens a nested array")
3438
public void testNestedList() {
3539
assertThat(flattener.flatten(singletonList(emptyList())))
3640
.isEmpty();
3741
}
3842

3943
@Disabled("Remove to run test")
4044
@Test
45+
@DisplayName("flattens array with just integers present")
4146
public void testASingleLevelOfNestingWithNoNulls() {
4247
assertThat(flattener.flatten(asList(1, asList('2', 3, 4, 5, "six", "7"), 8)))
4348
.containsExactly(1, '2', 3, 4, 5, "six", "7", 8);
4449
}
4550

4651
@Disabled("Remove to run test")
4752
@Test
53+
@DisplayName("5 level nesting")
4854
public void testFiveLevelsOfNestingWithNoNulls() {
4955
assertThat(flattener.flatten(
5056
asList(0,
@@ -59,6 +65,7 @@ public void testFiveLevelsOfNestingWithNoNulls() {
5965

6066
@Disabled("Remove to run test")
6167
@Test
68+
@DisplayName("6 level nesting")
6269
public void testSixLevelsOfNestingWithNoNulls() {
6370
assertThat(flattener.flatten(
6471
asList("one",
@@ -71,27 +78,31 @@ public void testSixLevelsOfNestingWithNoNulls() {
7178

7279
@Disabled("Remove to run test")
7380
@Test
81+
@DisplayName("null values are omitted from the final result")
7482
public void testNullValuesAreOmitted() {
7583
assertThat(flattener.flatten(asList("1", "two", null)))
7684
.containsExactly("1", "two");
7785
}
7886

7987
@Disabled("Remove to run test")
8088
@Test
89+
@DisplayName("consecutive null values at the front of the list are omitted from the final result")
8190
public void testConsecutiveNullValuesAtFrontOfListAreOmitted() {
8291
assertThat(flattener.flatten(asList(null, null, 3)))
8392
.containsExactly(3);
8493
}
8594

8695
@Disabled("Remove to run test")
8796
@Test
97+
@DisplayName("consecutive null values in the middle of the list are omitted from the final result")
8898
public void testConsecutiveNullValuesInMiddleOfListAreOmitted() {
8999
assertThat(flattener.flatten(asList(1, null, null, "4")))
90100
.containsExactly(1, "4");
91101
}
92102

93103
@Disabled("Remove to run test")
94104
@Test
105+
@DisplayName("6 level nest list with null values")
95106
public void testSixLevelsOfNestingWithNulls() {
96107
assertThat(flattener.flatten(
97108
asList("0",
@@ -107,6 +118,7 @@ public void testSixLevelsOfNestingWithNulls() {
107118

108119
@Disabled("Remove to run test")
109120
@Test
121+
@DisplayName("all values in nested list are null")
110122
public void testNestedListsFullOfNullsOnly() {
111123
assertThat(flattener.flatten(
112124
asList(null,

0 commit comments

Comments
 (0)