diff --git a/exercises/practice/matrix/src/test/java/MatrixTest.java b/exercises/practice/matrix/src/test/java/MatrixTest.java index 3406ea8d7..1f347e7d8 100644 --- a/exercises/practice/matrix/src/test/java/MatrixTest.java +++ b/exercises/practice/matrix/src/test/java/MatrixTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -6,10 +7,11 @@ public class MatrixTest { @Test + @DisplayName("extract row from one number matrix test") public void extractRowFromOneNumberMatrixTest() { String matrixAsString = "1"; int rowIndex = 1; - int[] expectedRow = {1}; + int[] expectedRow = { 1 }; Matrix matrix = new Matrix(matrixAsString); @@ -17,11 +19,12 @@ public void extractRowFromOneNumberMatrixTest() { } @Disabled("Remove to run test") + @DisplayName("extract row from matrix test") @Test public void extractRowFromMatrixTest() { String matrixAsString = "1 2\n3 4"; int rowIndex = 2; - int[] expectedRow = {3, 4}; + int[] expectedRow = { 3, 4 }; Matrix matrix = new Matrix(matrixAsString); @@ -30,10 +33,11 @@ public void extractRowFromMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract row from diff widths matrix test") public void extractRowFromDiffWidthsMatrixTest() { String matrixAsString = "1 2\n10 20"; int rowIndex = 2; - int[] expectedRow = {10, 20}; + int[] expectedRow = { 10, 20 }; Matrix matrix = new Matrix(matrixAsString); @@ -42,10 +46,11 @@ public void extractRowFromDiffWidthsMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract row from non square matrix test") public void extractRowFromNonSquareMatrixTest() { String matrixAsString = "1 2 3\n4 5 6\n7 8 9\n8 7 6"; int rowIndex = 4; - int[] expectedRow = {8, 7, 6}; + int[] expectedRow = { 8, 7, 6 }; Matrix matrix = new Matrix(matrixAsString); @@ -54,10 +59,11 @@ public void extractRowFromNonSquareMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract column from one number matrix test") public void extractColumnFromOneNumberMatrixTest() { String matrixAsString = "1"; int columnIndex = 1; - int[] expectedColumn = {1}; + int[] expectedColumn = { 1 }; Matrix matrix = new Matrix(matrixAsString); @@ -66,10 +72,11 @@ public void extractColumnFromOneNumberMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract column matrix test") public void extractColumnMatrixTest() { String matrixAsString = "1 2 3\n4 5 6\n7 8 9"; int columnIndex = 3; - int[] expectedColumn = {3, 6, 9}; + int[] expectedColumn = { 3, 6, 9 }; Matrix matrix = new Matrix(matrixAsString); @@ -78,10 +85,11 @@ public void extractColumnMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract column from non square matrix test") public void extractColumnFromNonSquareMatrixTest() { String matrixAsString = "1 2 3 4\n5 6 7 8\n9 8 7 6"; int columnIndex = 4; - int[] expectedColumn = {4, 8, 6}; + int[] expectedColumn = { 4, 8, 6 }; Matrix matrix = new Matrix(matrixAsString); @@ -90,10 +98,11 @@ public void extractColumnFromNonSquareMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("extract column from diff widths matrix test") public void extractColumnFromDiffWidthsMatrixTest() { String matrixAsString = "89 1903 3\n18 3 1\n9 4 800"; int columnIndex = 2; - int[] expectedColumn = {1903, 3, 4}; + int[] expectedColumn = { 1903, 3, 4 }; Matrix matrix = new Matrix(matrixAsString); diff --git a/exercises/practice/transpose/src/test/java/TransposeTest.java b/exercises/practice/transpose/src/test/java/TransposeTest.java index ad8f95f29..b9476d30c 100644 --- a/exercises/practice/transpose/src/test/java/TransposeTest.java +++ b/exercises/practice/transpose/src/test/java/TransposeTest.java @@ -1,6 +1,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; @@ -8,222 +9,235 @@ public class TransposeTest { private Transpose transpose; @BeforeEach + @DisplayName("setup") public void setup() { transpose = new Transpose(); } @Test + @DisplayName("empty string") public void emptyString() { assertThat(transpose.transpose("")).isEqualTo(""); } @Disabled("Remove to run test") @Test + @DisplayName("two characters in a row") public void twoCharactersInARow() { assertThat(transpose.transpose("A1")) - .isEqualTo( - "A" + - "\n1"); + .isEqualTo( + "A" + + "\n1"); } @Disabled("Remove to run test") @Test + @DisplayName("two characters in a column") public void twoCharactersInAColumn() { assertThat( - transpose.transpose( - "A\n" + - "1")) - .isEqualTo("A1"); + transpose.transpose( + "A\n" + + "1")) + .isEqualTo("A1"); } @Disabled("Remove to run test") @Test + @DisplayName("simple") public void simple() { assertThat( - transpose.transpose( - "ABC\n" + - "123")) - .isEqualTo( - "A1\n" + - "B2\n" + - "C3"); + transpose.transpose( + "ABC\n" + + "123")) + .isEqualTo( + "A1\n" + + "B2\n" + + "C3"); } @Disabled("Remove to run test") @Test + @DisplayName("single line") public void singleLine() { assertThat(transpose.transpose("Single line.")) - .isEqualTo( - "S\n" + - "i\n" + - "n\n" + - "g\n" + - "l\n" + - "e\n" + - " \n" + - "l\n" + - "i\n" + - "n\n" + - "e\n" + - "."); + .isEqualTo( + "S\n" + + "i\n" + + "n\n" + + "g\n" + + "l\n" + + "e\n" + + " \n" + + "l\n" + + "i\n" + + "n\n" + + "e\n" + + "."); } @Disabled("Remove to run test") @Test + @DisplayName("first line longer than second line") public void firstLineLongerThanSecondLine() { assertThat( - transpose.transpose( - "The fourth line.\n" + - "The fifth line.")) - .isEqualTo( - "TT\n" + - "hh\n" + - "ee\n" + - " \n" + - "ff\n" + - "oi\n" + - "uf\n" + - "rt\n" + - "th\n" + - "h \n" + - " l\n" + - "li\n" + - "in\n" + - "ne\n" + - "e.\n" + - "."); + transpose.transpose( + "The fourth line.\n" + + "The fifth line.")) + .isEqualTo( + "TT\n" + + "hh\n" + + "ee\n" + + " \n" + + "ff\n" + + "oi\n" + + "uf\n" + + "rt\n" + + "th\n" + + "h \n" + + " l\n" + + "li\n" + + "in\n" + + "ne\n" + + "e.\n" + + "."); } @Disabled("Remove to run test") @Test + @DisplayName("second line longer than first line") public void secondLineLongerThanFirstLine() { assertThat( - transpose.transpose( - "The first line.\n" + - "The second line.")) - .isEqualTo( - "TT\n" + - "hh\n" + - "ee\n" + - " \n" + - "fs\n" + - "ie\n" + - "rc\n" + - "so\n" + - "tn\n" + - " d\n" + - "l \n" + - "il\n" + - "ni\n" + - "en\n" + - ".e\n" + - " ."); + transpose.transpose( + "The first line.\n" + + "The second line.")) + .isEqualTo( + "TT\n" + + "hh\n" + + "ee\n" + + " \n" + + "fs\n" + + "ie\n" + + "rc\n" + + "so\n" + + "tn\n" + + " d\n" + + "l \n" + + "il\n" + + "ni\n" + + "en\n" + + ".e\n" + + " ."); } @Disabled("Remove to run test") @Test + @DisplayName("mixed line length") public void mixedLineLength() { assertThat( - transpose.transpose( - "The longest line.\n" + - "A long line.\n" + - "A longer line.\n" + - "A line.")) - .isEqualTo( - "TAAA\n" + - "h \n" + - "elll\n" + - " ooi\n" + - "lnnn\n" + - "ogge\n" + - "n e.\n" + - "glr\n" + - "ei \n" + - "snl\n" + - "tei\n" + - " .n\n" + - "l e\n" + - "i .\n" + - "n\n" + - "e\n" + - "."); + transpose.transpose( + "The longest line.\n" + + "A long line.\n" + + "A longer line.\n" + + "A line.")) + .isEqualTo( + "TAAA\n" + + "h \n" + + "elll\n" + + " ooi\n" + + "lnnn\n" + + "ogge\n" + + "n e.\n" + + "glr\n" + + "ei \n" + + "snl\n" + + "tei\n" + + " .n\n" + + "l e\n" + + "i .\n" + + "n\n" + + "e\n" + + "."); } @Disabled("Remove to run test") @Test + @DisplayName("square") public void square() { assertThat( - transpose.transpose( - "HEART\n" + - "EMBER\n" + - "ABUSE\n" + - "RESIN\n" + - "TREND")) - .isEqualTo( - "HEART\n" + - "EMBER\n" + - "ABUSE\n" + - "RESIN\n" + - "TREND"); + transpose.transpose( + "HEART\n" + + "EMBER\n" + + "ABUSE\n" + + "RESIN\n" + + "TREND")) + .isEqualTo( + "HEART\n" + + "EMBER\n" + + "ABUSE\n" + + "RESIN\n" + + "TREND"); } @Disabled("Remove to run test") @Test + @DisplayName("rectangle") public void rectangle() { assertThat( - transpose.transpose( - "FRACTURE\n" + - "OUTLINED\n" + - "BLOOMING\n" + - "SEPTETTE")) - .isEqualTo( - "FOBS\n" + - "RULE\n" + - "ATOP\n" + - "CLOT\n" + - "TIME\n" + - "UNIT\n" + - "RENT\n" + - "EDGE"); + transpose.transpose( + "FRACTURE\n" + + "OUTLINED\n" + + "BLOOMING\n" + + "SEPTETTE")) + .isEqualTo( + "FOBS\n" + + "RULE\n" + + "ATOP\n" + + "CLOT\n" + + "TIME\n" + + "UNIT\n" + + "RENT\n" + + "EDGE"); } @Disabled("Remove to run test") @Test + @DisplayName("triangle") public void triangle() { assertThat( - transpose.transpose( - "T\n" + - "EE\n" + - "AAA\n" + - "SSSS\n" + - "EEEEE\n" + - "RRRRRR")) - .isEqualTo( - "TEASER\n" + - " EASER\n" + - " ASER\n" + - " SER\n" + - " ER\n" + - " R"); + transpose.transpose( + "T\n" + + "EE\n" + + "AAA\n" + + "SSSS\n" + + "EEEEE\n" + + "RRRRRR")) + .isEqualTo( + "TEASER\n" + + " EASER\n" + + " ASER\n" + + " SER\n" + + " ER\n" + + " R"); } - + @Disabled("Remove to run test") @Test + @DisplayName("jagged triangle") public void jaggedTriangle() { assertThat( - transpose.transpose( - "11\n" + - "2\n" + - "3333\n" + - "444\n" + - "555555\n" + - "66666")) - .isEqualTo( - "123456\n" + - "1 3456\n" + - " 3456\n" + - " 3 56\n" + - " 56\n" + - " 5"); + transpose.transpose( + "11\n" + + "2\n" + + "3333\n" + + "444\n" + + "555555\n" + + "66666")) + .isEqualTo( + "123456\n" + + "1 3456\n" + + " 3456\n" + + " 3 56\n" + + " 56\n" + + " 5"); } } diff --git a/exercises/practice/zipper/src/test/java/ZipperTest.java b/exercises/practice/zipper/src/test/java/ZipperTest.java index 842ca8be2..19d941ff6 100644 --- a/exercises/practice/zipper/src/test/java/ZipperTest.java +++ b/exercises/practice/zipper/src/test/java/ZipperTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; @@ -10,6 +11,7 @@ public class ZipperTest { BinaryTree binaryTree; @BeforeEach + @DisplayName("setup") public void setup() { zipper = new Zipper(1); binaryTree = new BinaryTree(zipper); @@ -21,12 +23,14 @@ public void setup() { } @Test + @DisplayName("test to tree") public void testToTree() { assertThat(zipper.toTree()).isEqualTo(binaryTree); } @Disabled("Remove to run test") @Test + @DisplayName("test left right and value") public void testLeftRightAndValue() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.getValue()).isEqualTo(3); @@ -34,6 +38,7 @@ public void testLeftRightAndValue() { @Disabled("Remove to run test") @Test + @DisplayName("test dead end") public void testDeadEnd() { zipper = binaryTree.getRoot(); assertThat(zipper.left.left).isNull(); @@ -41,6 +46,7 @@ public void testDeadEnd() { @Disabled("Remove to run test") @Test + @DisplayName("test to tree from deep focus") public void testToTreeFromDeepFocus() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.toTree()).isEqualTo(binaryTree); @@ -48,6 +54,7 @@ public void testToTreeFromDeepFocus() { @Disabled("Remove to run test") @Test + @DisplayName("test traversing up from top") public void testTraversingUpFromTop() { zipper = binaryTree.getRoot(); assertThat(zipper.up).isNull(); @@ -55,6 +62,7 @@ public void testTraversingUpFromTop() { @Disabled("Remove to run test") @Test + @DisplayName("test left right and up") public void testLeftRightAndUp() { zipper = binaryTree.getRoot(); assertThat(zipper.left.up.right.up.left.right.getValue()).isEqualTo(3); @@ -62,6 +70,7 @@ public void testLeftRightAndUp() { @Disabled("Remove to run test") @Test + @DisplayName("test ability to return after multiple level descend") public void testAbilityToReturnAfterMultipleLevelDescend() { zipper = binaryTree.getRoot(); assertThat(zipper.left.right.up.up.getValue()).isEqualTo(1); @@ -69,81 +78,81 @@ public void testAbilityToReturnAfterMultipleLevelDescend() { @Disabled("Remove to run test") @Test + @DisplayName("test set value") public void testSetValue() { zipper = binaryTree.getRoot(); zipper = zipper.left; zipper.setValue(5); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { " + - "value: 5, " + - "left: null, " + - "right: { " + - "value: 3, " + - "left: null, " + - "right: null } }, " + + "value: 5, " + + "left: null, " + "right: { " + - "value: 4, " + - "left: null, " + - "right: null }"; + "value: 3, " + + "left: null, " + + "right: null } }, " + + "right: { " + + "value: 4, " + + "left: null, " + + "right: null }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); } @Disabled("Remove to run test") @Test + @DisplayName("test set value after traversing up") public void testSetValueAfterTraversingUp() { zipper = binaryTree.getRoot(); zipper = zipper.left.right.up; zipper.setValue(5); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { " + - "value: 5, " + - "left: null, " + - "right: { " + - "value: 3, " + - "left: null, " + - "right: null } }, " + + "value: 5, " + + "left: null, " + + "right: { " + + "value: 3, " + + "left: null, " + + "right: null } }, " + "right: { " + - "value: 4, " + - "left: null, " + - "right: null }"; + "value: 4, " + + "left: null, " + + "right: null }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); } @Disabled("Remove to run test") @Test + @DisplayName("test set left with leaf") public void testSetLeftWithLeaf() { zipper = binaryTree.getRoot(); zipper = zipper.left; zipper.setLeft(new Zipper(5)); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { " + - "value: 2, " + - "left: { " + - "value: 5, " + - "left: null, " + - "right: null }, " + - "right: { " + - "value: 3, " + - "left: null, " + - "right: null } }, " + + "value: 2, " + + "left: { " + + "value: 5, " + + "left: null, " + + "right: null }, " + + "right: { " + + "value: 3, " + + "left: null, " + + "right: null } }, " + "right: { " + - "value: 4, " + - "left: null, " + - "right: null }"; + "value: 4, " + + "left: null, " + + "right: null }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); } @Disabled("Remove to run test") @Test + @DisplayName("test set right with null") public void testSetRightWithNull() { zipper = binaryTree.getRoot(); zipper = zipper.left; zipper.setRight(null); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { value: 2, left: null, right: null }, " + "right: { value: 4, left: null, right: null }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); @@ -151,58 +160,59 @@ public void testSetRightWithNull() { @Disabled("Remove to run test") @Test + @DisplayName("test set right with subtree") public void testSetRightWithSubtree() { BinaryTree subtree = new BinaryTree(6); subtree.getRoot().setLeft(new Zipper(7)); subtree.getRoot().setRight(new Zipper(8)); zipper = binaryTree.getRoot(); zipper.setRight(subtree.getRoot()); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { " + - "value: 2, " + - "left: null, " + - "right: { " + - "value: 3, " + - "left: null, " + - "right: null } }, " + + "value: 2, " + + "left: null, " + "right: { " + - "value: 6, " + - "left: { " + - "value: 7, " + - "left: null, " + - "right: null }, " + - "right: { " + - "value: 8, " + - "left: null, " + - "right: null } }"; + "value: 3, " + + "left: null, " + + "right: null } }, " + + "right: { " + + "value: 6, " + + "left: { " + + "value: 7, " + + "left: null, " + + "right: null }, " + + "right: { " + + "value: 8, " + + "left: null, " + + "right: null } }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); } @Disabled("Remove to run test") @Test + @DisplayName("test set value on deep focus") public void testSetValueOnDeepFocus() { zipper = binaryTree.getRoot(); zipper = zipper.left.right; zipper.setValue(5); - String expected = - "value: 1, " + + String expected = "value: 1, " + "left: { " + - "value: 2, " + - "left: null, " + - "right: { " + - "value: 5, " + - "left: null, " + - "right: null } }, " + + "value: 2, " + + "left: null, " + + "right: { " + + "value: 5, " + + "left: null, " + + "right: null } }, " + "right: { " + - "value: 4, " + - "left: null, " + - "right: null }"; + "value: 4, " + + "left: null, " + + "right: null }"; assertThat(zipper.toTree().printTree()).isEqualTo(expected); } @Disabled("Remove to run test") @Test + @DisplayName("different path to same zipper") public void differentPathToSameZipper() { Zipper zipper1 = binaryTree.getRoot().left.up.right; Zipper zipper2 = binaryTree.getRoot().right;