From 72a4095c4ceb235a9ebb06b7c4fbc8ad7a57241f Mon Sep 17 00:00:00 2001 From: ThanhNIT Date: Thu, 27 Nov 2025 15:02:25 +0700 Subject: [PATCH] Added tests for tasks 556-3142 --- .../SolutionTest.kt | 65 ++++++++++ .../SolutionTest.kt | 112 ++++++++++++++++++ .../s1185_day_of_the_week/SolutionTest.kt | 65 ++++++++++ .../SolutionTest.kt | 35 ++++++ .../SolutionTest.kt | 74 ++++++++++++ 5 files changed, 351 insertions(+) diff --git a/src/test/kotlin/g0501_0600/s0556_next_greater_element_iii/SolutionTest.kt b/src/test/kotlin/g0501_0600/s0556_next_greater_element_iii/SolutionTest.kt index a88fd3977..3d1e5c620 100644 --- a/src/test/kotlin/g0501_0600/s0556_next_greater_element_iii/SolutionTest.kt +++ b/src/test/kotlin/g0501_0600/s0556_next_greater_element_iii/SolutionTest.kt @@ -14,4 +14,69 @@ internal class SolutionTest { fun nextGreaterElement2() { assertThat(Solution().nextGreaterElement(21), equalTo(-1)) } + + @Test + fun nextGreaterElement3() { + assertThat(Solution().nextGreaterElement(1234), equalTo(1243)) + } + + @Test + fun nextGreaterElement4() { + assertThat(Solution().nextGreaterElement(4321), equalTo(-1)) + } + + @Test + fun nextGreaterElement5() { + assertThat(Solution().nextGreaterElement(115), equalTo(151)) + } + + @Test + fun nextGreaterElement6() { + assertThat(Solution().nextGreaterElement(111), equalTo(-1)) + } + + @Test + fun nextGreaterElement7() { + assertThat(Solution().nextGreaterElement(12443322), equalTo(13222344)) + } + + @Test + fun nextGreaterElement8() { + assertThat(Solution().nextGreaterElement(230241), equalTo(230412)) + } + + @Test + fun nextGreaterElement9() { + assertThat(Solution().nextGreaterElement(1999999999), equalTo(-1)) + } + + @Test + fun nextGreaterElement10() { + assertThat(Solution().nextGreaterElement(218765), equalTo(251678)) + } + + @Test + fun nextGreaterElement11() { + assertThat(Solution().nextGreaterElement(7), equalTo(-1)) + } + + @Test + fun nextGreaterElement12() { + assertThat(Solution().nextGreaterElement(132), equalTo(213)) + } + + @Test + fun nextGreaterElement13() { + assertThat(Solution().nextGreaterElement(534976), equalTo(536479)) + } + + @Test + fun nextGreaterElement14() { + assertThat(Solution().nextGreaterElement(1998), equalTo(8199)) + } + + @Test + fun nextGreaterElement15() { + assertThat(Solution().nextGreaterElement(2147483647), equalTo(-1)) + } } diff --git a/src/test/kotlin/g0801_0900/s0840_magic_squares_in_grid/SolutionTest.kt b/src/test/kotlin/g0801_0900/s0840_magic_squares_in_grid/SolutionTest.kt index a0f6f6947..053dba5c0 100644 --- a/src/test/kotlin/g0801_0900/s0840_magic_squares_in_grid/SolutionTest.kt +++ b/src/test/kotlin/g0801_0900/s0840_magic_squares_in_grid/SolutionTest.kt @@ -18,4 +18,116 @@ internal class SolutionTest { fun numMagicSquaresInside2() { assertThat(Solution().numMagicSquaresInside(arrayOf(intArrayOf(8))), equalTo(0)) } + + @Test + fun numMagicSquaresInside3() { + val grid = arrayOf( + intArrayOf(8, 1, 6), + intArrayOf(3, 5, 7), + intArrayOf(4, 9, 2), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(1)) + } + + @Test + fun numMagicSquaresInside4() { + val grid = arrayOf( + intArrayOf(8, 1, 6, 8, 1, 6), + intArrayOf(3, 5, 7, 3, 5, 7), + intArrayOf(4, 9, 2, 4, 9, 2), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(2)) + } + + @Test + fun numMagicSquaresInside5() { + val grid = arrayOf( + intArrayOf(8, 1, 6, 1), + intArrayOf(3, 5, 7, 5), + intArrayOf(4, 9, 2, 9), + intArrayOf(8, 1, 6, 1), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(1)) + } + + @Test + fun numMagicSquaresInside6() { + val grid = arrayOf( + intArrayOf(8, 1, 6), + intArrayOf(3, 5, 7), + intArrayOf(4, 9, 8), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside7() { + val grid = arrayOf( + intArrayOf(8, 1, 6), + intArrayOf(3, 5, 20), + intArrayOf(4, 9, 2), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside8() { + val grid = arrayOf( + intArrayOf(8, 1, 6), + intArrayOf(3, 5, 7), + intArrayOf(4, 2, 9), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside9() { + val grid = arrayOf( + intArrayOf(8, 1, 6), + intArrayOf(3, 5, 7), + intArrayOf(4, 9, 3), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside10() { + val grid = arrayOf( + intArrayOf(1, 2), + intArrayOf(3, 4), + intArrayOf(5, 6), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside11() { + val grid = arrayOf( + intArrayOf(1, 2, 3), + intArrayOf(4, 5, 6), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside12() { + val grid = arrayOf( + intArrayOf(1, 2, 3, 8), + intArrayOf(4, 5, 6, 1), + intArrayOf(7, 8, 9, 6), + intArrayOf(3, 5, 7, 7), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(0)) + } + + @Test + fun numMagicSquaresInside13() { + val grid = arrayOf( + intArrayOf(8, 1, 6, 8), + intArrayOf(3, 5, 7, 3), + intArrayOf(4, 9, 2, 4), + intArrayOf(8, 1, 6, 99), + ) + assertThat(Solution().numMagicSquaresInside(grid), equalTo(1)) + } } diff --git a/src/test/kotlin/g1101_1200/s1185_day_of_the_week/SolutionTest.kt b/src/test/kotlin/g1101_1200/s1185_day_of_the_week/SolutionTest.kt index 6ac9973c7..614b1bd16 100644 --- a/src/test/kotlin/g1101_1200/s1185_day_of_the_week/SolutionTest.kt +++ b/src/test/kotlin/g1101_1200/s1185_day_of_the_week/SolutionTest.kt @@ -19,4 +19,69 @@ internal class SolutionTest { fun dayOfTheWeek3() { assertThat(Solution().dayOfTheWeek(15, 8, 1993), equalTo("Sunday")) } + + @Test + fun dayOfTheWeek4() { + assertThat(Solution().dayOfTheWeek(1, 1, 1971), equalTo("Friday")) + } + + @Test + fun dayOfTheWeek5() { + assertThat(Solution().dayOfTheWeek(29, 2, 2020), equalTo("Saturday")) + } + + @Test + fun dayOfTheWeek6() { + assertThat(Solution().dayOfTheWeek(1, 3, 2020), equalTo("Sunday")) + } + + @Test + fun dayOfTheWeek7() { + assertThat(Solution().dayOfTheWeek(28, 2, 2019), equalTo("Thursday")) + } + + @Test + fun dayOfTheWeek8() { + assertThat(Solution().dayOfTheWeek(31, 12, 1999), equalTo("Friday")) + } + + @Test + fun dayOfTheWeek9() { + assertThat(Solution().dayOfTheWeek(1, 1, 2001), equalTo("Monday")) + } + + @Test + fun dayOfTheWeek10() { + assertThat(Solution().dayOfTheWeek(1, 1, 2000), equalTo("Saturday")) + } + + @Test + fun dayOfTheWeek11() { + assertThat(Solution().dayOfTheWeek(1, 3, 1900), equalTo("Monday")) + } + + @Test + fun dayOfTheWeek12() { + assertThat(Solution().dayOfTheWeek(15, 6, 2024), equalTo("Saturday")) + } + + @Test + fun dayOfTheWeek13() { + assertThat(Solution().dayOfTheWeek(30, 11, 1985), equalTo("Saturday")) + } + + @Test + fun dayOfTheWeek14() { + assertThat(Solution().dayOfTheWeek(20, 4, 1975), equalTo("Sunday")) + } + + @Test + fun dayOfTheWeek15() { + assertThat(Solution().dayOfTheWeek(5, 1, 1971), equalTo("Tuesday")) + } + + @Test + fun dayOfTheWeek16() { + assertThat(Solution().dayOfTheWeek(6, 1, 1971), equalTo("Wednesday")) + } } diff --git a/src/test/kotlin/g2401_2500/s2481_minimum_cuts_to_divide_a_circle/SolutionTest.kt b/src/test/kotlin/g2401_2500/s2481_minimum_cuts_to_divide_a_circle/SolutionTest.kt index 9c44b7c78..9beef1ea4 100644 --- a/src/test/kotlin/g2401_2500/s2481_minimum_cuts_to_divide_a_circle/SolutionTest.kt +++ b/src/test/kotlin/g2401_2500/s2481_minimum_cuts_to_divide_a_circle/SolutionTest.kt @@ -14,4 +14,39 @@ internal class SolutionTest { fun numberOfCuts2() { assertThat(Solution().numberOfCuts(3), equalTo(3)) } + + @Test + fun numberOfCuts3() { + assertThat(Solution().numberOfCuts(1), equalTo(0)) + } + + @Test + fun numberOfCuts4() { + assertThat(Solution().numberOfCuts(6), equalTo(3)) + } + + @Test + fun numberOfCuts5() { + assertThat(Solution().numberOfCuts(5), equalTo(5)) + } + + @Test + fun numberOfCuts6() { + assertThat(Solution().numberOfCuts(100), equalTo(50)) + } + + @Test + fun numberOfCuts7() { + assertThat(Solution().numberOfCuts(101), equalTo(101)) + } + + @Test + fun numberOfCuts8() { + assertThat(Solution().numberOfCuts(2), equalTo(1)) + } + + @Test + fun numberOfCuts9() { + assertThat(Solution().numberOfCuts(3), equalTo(3)) + } } diff --git a/src/test/kotlin/g3101_3200/s3142_check_if_grid_satisfies_conditions/SolutionTest.kt b/src/test/kotlin/g3101_3200/s3142_check_if_grid_satisfies_conditions/SolutionTest.kt index f6e66312a..19201544b 100644 --- a/src/test/kotlin/g3101_3200/s3142_check_if_grid_satisfies_conditions/SolutionTest.kt +++ b/src/test/kotlin/g3101_3200/s3142_check_if_grid_satisfies_conditions/SolutionTest.kt @@ -20,4 +20,78 @@ internal class SolutionTest { equalTo(false), ) } + + @Test + fun satisfiesConditions3() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1), intArrayOf(2), intArrayOf(3))), equalTo(false)) + } + + @Test + fun satisfiesConditions4() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1), intArrayOf(1))), equalTo(true)) + } + + @Test + fun satisfiesConditions5() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1, 2, 3))), equalTo(true)) + } + + @Test + fun satisfiesConditions6() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(1, 1))), equalTo(false)) + } + + @Test + fun satisfiesConditions7() { + assertThat( + Solution().satisfiesConditions(arrayOf(intArrayOf(1, 2, 2), intArrayOf(3, 4, 5))), + equalTo(false), + ) + } + + @Test + fun satisfiesConditions8() { + val grid = arrayOf( + intArrayOf(1, 0, 1), + intArrayOf(0, 1, 0), + intArrayOf(1, 0, 1), + ) + assertThat(Solution().satisfiesConditions(grid), equalTo(false)) + } + + @Test + fun satisfiesConditions9() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(5, 1), intArrayOf(5, 0))), equalTo(true)) + } + + @Test + fun satisfiesConditions10() { + assertThat( + Solution().satisfiesConditions(arrayOf(intArrayOf(1, 0), intArrayOf(2, 2))), + equalTo(false), + ) + } + + @Test + fun satisfiesConditions11() { + assertThat(Solution().satisfiesConditions(arrayOf(intArrayOf(7))), equalTo(true)) + } + + @Test + fun satisfiesConditions12() { + val grid = arrayOf( + intArrayOf(4, 1, 5, 2), + intArrayOf(3, 0, 4, 1), + ) + assertThat(Solution().satisfiesConditions(grid), equalTo(false)) + } + + @Test + fun satisfiesConditions13() { + val grid = arrayOf( + intArrayOf(2, 3, 3, 1), + intArrayOf(1, 0, 4, 2), + ) + assertThat(Solution().satisfiesConditions(grid), equalTo(false)) + } }