From 492f2080f2848ffc07331192786f32bffa14a626 Mon Sep 17 00:00:00 2001 From: Aditya5009 <138042821+Aditya5009@users.noreply.github.com> Date: Fri, 19 Sep 2025 23:56:21 +0530 Subject: [PATCH 1/5] MatrixTest, LuhnValidatorTest, PangramCheckerTest --- .../luhn/src/test/java/LuhnValidatorTest.java | 30 +++++++++++++++++-- .../matrix/src/test/java/MatrixTest.java | 25 +++++++++++----- .../src/test/java/PangramCheckerTest.java | 11 +++++++ 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java index 12d3e5f3f..a3a6bca44 100644 --- a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java +++ b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; 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; @@ -13,138 +14,163 @@ public void setUp() { } @Test + @DisplayName("single digit strings can not be valid") public void testSingleDigitStringInvalid() { assertThat(luhnValidator.isValid("1")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("a single zero is invalid") public void testSingleZeroIsInvalid() { assertThat(luhnValidator.isValid("0")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("a simple valid SIN that remains valid if reversed") public void testSimpleValidSINReversedRemainsValid() { assertThat(luhnValidator.isValid("059")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("a simple valid SIN that becomes invalid if reversed") public void testSimpleValidSINReversedBecomesInvalid() { assertThat(luhnValidator.isValid("59")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("a valid Canadian SIN") public void testValidCanadianSINValid() { assertThat(luhnValidator.isValid("055 444 285")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("invalid Canadian SIN") public void testInvalidCanadianSINInvalid() { assertThat(luhnValidator.isValid("055 444 286")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("invalid credit card") public void testInvalidCreditCardInvalid() { assertThat(luhnValidator.isValid("8273 1232 7352 0569")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("invalid long number with an even remainder") public void testInvalidLongNumberWithAnEvenRemainder() { assertThat(luhnValidator.isValid("1 2345 6789 1234 5678 9012")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("invalid long number with a remainder divisible by 5") public void testInvalidLongNumberWithARemainderDivisibleBy5() { assertThat(luhnValidator.isValid("1 2345 6789 1234 5678 9013")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("valid number with an even number of digits") public void testValidNumberWithAnEvenNumberOfDigits() { assertThat(luhnValidator.isValid("095 245 88")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("valid number with an odd number of spaces") public void testValidNumberWithAnOddNumberOfSpaces() { assertThat(luhnValidator.isValid("234 567 891 234")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("valid strings with a non-digit added at the end become invalid") public void testValidStringsWithANonDigitAtEndInvalid() { assertThat(luhnValidator.isValid("059a")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("valid strings with punctuation included become invalid") public void testStringContainingPunctuationInvalid() { assertThat(luhnValidator.isValid("055-444-285")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("valid strings with symbols included become invalid") public void testStringContainingSymbolsInvalid() { assertThat(luhnValidator.isValid("055# 444$ 285")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("single zero with space is invalid") public void testSingleSpaceWithZeroInvalid() { assertThat(luhnValidator.isValid(" 0")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("more than a single zero is valid") public void testMoreThanSingleZeroValid() { assertThat(luhnValidator.isValid("0000 0")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("input digit 9 is correctly converted to output digit 9") public void testDigitNineConvertedToOutputNine() { assertThat(luhnValidator.isValid("091")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("very long input is valid") public void testVeryLongInputIsValid() { assertThat(luhnValidator.isValid("9999999999 9999999999 9999999999 9999999999")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("valid luhn with an odd number of digits and non zero first digit") public void testValidLuhnWithOddNumberOfDigitsAndNonZeroFirstDigit() { assertThat(luhnValidator.isValid("109")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("using ascii value for non-doubled non-digit isn't allowed") public void testUsingASCIIValueForNonDoubledNonDigitNotAllowed() { assertThat(luhnValidator.isValid("055b 444 285")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("using ascii value for doubled non-digit isn't allowed") public void testUsingASCIIValueForDoubledNonDigitNotAllowed() { assertThat(luhnValidator.isValid(":9")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed") public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed() { assertThat(luhnValidator.isValid("59%59")).isFalse(); } - /* The following test diverges from the canonical test data. This is because the corresponding canonical test does - * not account for Java specific functions (such as Character.getNumericValue()), which can be part of incorrect yet + /* + * The following test diverges from the canonical test data. This is because the + * corresponding canonical test does + * not account for Java specific functions (such as + * Character.getNumericValue()), which can be part of incorrect yet * passing implementations. For more detail, check out issue #972 here: * (https://github.com/exercism/java/issues/972). */ diff --git a/exercises/practice/matrix/src/test/java/MatrixTest.java b/exercises/practice/matrix/src/test/java/MatrixTest.java index 3406ea8d7..97af2e870 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") public void extractRowFromOneNumberMatrixTest() { String matrixAsString = "1"; int rowIndex = 1; - int[] expectedRow = {1}; + int[] expectedRow = { 1 }; Matrix matrix = new Matrix(matrixAsString); @@ -18,10 +20,11 @@ public void extractRowFromOneNumberMatrixTest() { @Disabled("Remove to run test") @Test + @DisplayName("can extract row") 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 where numbers have different widths") 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("can extract row from non-square matrix with no corresponding column") 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") 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("can extract column") 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("can extract column from non-square matrix with no corresponding row") 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 where numbers have different widths") 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/pangram/src/test/java/PangramCheckerTest.java b/exercises/practice/pangram/src/test/java/PangramCheckerTest.java index 63a83513f..981e40172 100644 --- a/exercises/practice/pangram/src/test/java/PangramCheckerTest.java +++ b/exercises/practice/pangram/src/test/java/PangramCheckerTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; 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; @@ -14,60 +15,70 @@ public void setup() { } @Test + @DisplayName("empty sentence") public void emptySentenceIsNotPangram() { assertThat(pangramChecker.isPangram("")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("perfect lower case") public void perfectLowerCasePhraseIsPangram() { assertThat(pangramChecker.isPangram("abcdefghijklmnopqrstuvwxyz")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("only lower case") public void phraseWithOnlyLowerCaseIsPangram() { assertThat(pangramChecker.isPangram("the quick brown fox jumps over the lazy dog")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("missing the letter 'x'") public void phraseMissingCharacterXIsNotPangram() { assertThat(pangramChecker.isPangram("a quick movement of the enemy will jeopardize five gunboats")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("missing the letter 'h'") public void phraseMissingCharacterHIsNotPangram() { assertThat(pangramChecker.isPangram("five boxing wizards jump quickly at it")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("with underscores") public void phraseWithUnderscoresIsPangram() { assertThat(pangramChecker.isPangram("the_quick_brown_fox_jumps_over_the_lazy_dog")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("with numbers") public void phraseWithNumbersIsPangram() { assertThat(pangramChecker.isPangram("the 1 quick brown fox jumps over the 2 lazy dogs")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("missing letters replaced by numbers") public void phraseWithMissingLettersReplacedByNumbersIsNotPangram() { assertThat(pangramChecker.isPangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")).isFalse(); } @Disabled("Remove to run test") @Test + @DisplayName("mixed case and punctuation") public void phraseWithMixedCaseAndPunctuationIsPangram() { assertThat(pangramChecker.isPangram("\"Five quacking Zephyrs jolt my wax bed.\"")).isTrue(); } @Disabled("Remove to run test") @Test + @DisplayName("case insensitive") public void caseInsensitivePhraseIsNotPangram() { assertThat(pangramChecker.isPangram("abcdefghijklm ABCDEFGHIJKLM")).isFalse(); } From a962107ca183c4e94eb3cecfbe06c668a7b264c8 Mon Sep 17 00:00:00 2001 From: Aditya5009 <138042821+Aditya5009@users.noreply.github.com> Date: Mon, 22 Sep 2025 11:25:02 +0530 Subject: [PATCH 2/5] change --- exercises/practice/matrix/src/test/java/MatrixTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/matrix/src/test/java/MatrixTest.java b/exercises/practice/matrix/src/test/java/MatrixTest.java index 97af2e870..502337e6d 100644 --- a/exercises/practice/matrix/src/test/java/MatrixTest.java +++ b/exercises/practice/matrix/src/test/java/MatrixTest.java @@ -11,7 +11,7 @@ public class MatrixTest { public void extractRowFromOneNumberMatrixTest() { String matrixAsString = "1"; int rowIndex = 1; - int[] expectedRow = { 1 }; + int[] expectedRow = {1}; Matrix matrix = new Matrix(matrixAsString); From 9fd14efb82c9e87a80643bbb66798052cbeeefbb Mon Sep 17 00:00:00 2001 From: Aditya5009 <138042821+Aditya5009@users.noreply.github.com> Date: Mon, 22 Sep 2025 23:17:18 +0530 Subject: [PATCH 3/5] MatrixTest, LuhnValidatorTest, PangramCheckerTest --- .../luhn/src/test/java/LuhnValidatorTest.java | 7 ++----- .../practice/matrix/src/test/java/MatrixTest.java | 14 +++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java index a3a6bca44..0857bf52a 100644 --- a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java +++ b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java @@ -166,11 +166,8 @@ public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed() assertThat(luhnValidator.isValid("59%59")).isFalse(); } - /* - * The following test diverges from the canonical test data. This is because the - * corresponding canonical test does - * not account for Java specific functions (such as - * Character.getNumericValue()), which can be part of incorrect yet + /* The following test diverges from the canonical test data. This is because the corresponding canonical test does + * not account for Java specific functions (such as * Character.getNumericValue()), which can be part of incorrect yet * passing implementations. For more detail, check out issue #972 here: * (https://github.com/exercism/java/issues/972). */ diff --git a/exercises/practice/matrix/src/test/java/MatrixTest.java b/exercises/practice/matrix/src/test/java/MatrixTest.java index 502337e6d..5eb9ccfb4 100644 --- a/exercises/practice/matrix/src/test/java/MatrixTest.java +++ b/exercises/practice/matrix/src/test/java/MatrixTest.java @@ -24,7 +24,7 @@ public void extractRowFromOneNumberMatrixTest() { 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); @@ -37,7 +37,7 @@ public void extractRowFromMatrixTest() { 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); @@ -50,7 +50,7 @@ public void extractRowFromDiffWidthsMatrixTest() { 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); @@ -63,7 +63,7 @@ public void extractRowFromNonSquareMatrixTest() { public void extractColumnFromOneNumberMatrixTest() { String matrixAsString = "1"; int columnIndex = 1; - int[] expectedColumn = { 1 }; + int[] expectedColumn = {1}; Matrix matrix = new Matrix(matrixAsString); @@ -76,7 +76,7 @@ public void extractColumnFromOneNumberMatrixTest() { 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); @@ -89,7 +89,7 @@ public void extractColumnMatrixTest() { 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); @@ -102,7 +102,7 @@ public void extractColumnFromNonSquareMatrixTest() { 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); From 82e88756d68ee6dba1d0de9b6a7f553cb82f23d1 Mon Sep 17 00:00:00 2001 From: Aditya5009 <138042821+Aditya5009@users.noreply.github.com> Date: Tue, 23 Sep 2025 19:41:30 +0530 Subject: [PATCH 4/5] MatrixTest, LuhnValidatorTest, PangramCheckerTest --- exercises/practice/luhn/src/test/java/LuhnValidatorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java index 0857bf52a..b16f805fd 100644 --- a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java +++ b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java @@ -167,7 +167,7 @@ public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed() } /* The following test diverges from the canonical test data. This is because the corresponding canonical test does - * not account for Java specific functions (such as * Character.getNumericValue()), which can be part of incorrect yet + * not account for Java specific functions (such as Character.getNumericValue()), which can be part of incorrect yet * passing implementations. For more detail, check out issue #972 here: * (https://github.com/exercism/java/issues/972). */ From 7d26f17fbecca8121d4a2350464751210662d9e8 Mon Sep 17 00:00:00 2001 From: Aditya5009 <138042821+Aditya5009@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:00:06 +0530 Subject: [PATCH 5/5] MatrixTest, LuhnValidatorTest, PangramCheckerTest --- exercises/practice/luhn/src/test/java/LuhnValidatorTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java index b16f805fd..bc0c6d7dc 100644 --- a/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java +++ b/exercises/practice/luhn/src/test/java/LuhnValidatorTest.java @@ -173,7 +173,8 @@ public void testNonNumericNonSpaceCharInMiddleWithSumDivisibleBy10IsNotAllowed() */ @Disabled("Remove to run test") @Test - public void testStringContainingSymbolsInvalidJavaTrackSpecific() { + @DisplayName("string containing symbols is invalid (Java track specific)") + public void testStringContainingSymbolsIsInvalidJavaTrackSpecific() { assertThat(luhnValidator.isValid("85&")).isFalse(); } }