Skip to content

Commit 2f29713

Browse files
committed
Improved tests
1 parent 971d241 commit 2f29713

File tree

40 files changed

+159
-158
lines changed

40 files changed

+159
-158
lines changed

src/main/kotlin/g0201_0300/s0212_word_search_ii/Solution.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ package g0201_0300.s0212_word_search_ii
66
@Suppress("NAME_SHADOWING")
77
class Solution {
88
private var root: Tree? = null
9-
fun findWords(board: Array<CharArray>, words: Array<String?>): List<String> {
10-
if (board.size < 1 || board[0].size < 1) {
9+
10+
fun findWords(board: Array<CharArray>, words: Array<String>): List<String> {
11+
if (board.isEmpty() || board[0].isEmpty()) {
1112
return emptyList()
1213
}
1314
root = Tree()
1415
for (word in words) {
15-
Tree.addWord(root, word!!)
16+
Tree.addWord(root, word)
1617
}
1718
val collected: MutableList<String> = ArrayList()
1819
for (i in board.indices) {

src/test/kotlin/g0201_0300/s0212_word_search_ii/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class SolutionTest {
1313
charArrayOf('i', 'h', 'k', 'r'),
1414
charArrayOf('i', 'f', 'l', 'v'),
1515
)
16-
val words = arrayOf<String?>("oath", "pea", "eat", "rain")
16+
val words = arrayOf<String>("oath", "pea", "eat", "rain")
1717
val expected: MutableList<String> = ArrayList()
1818
expected.add("oath")
1919
expected.add("eat")
@@ -23,7 +23,7 @@ internal class SolutionTest {
2323
@Test
2424
fun findWords2() {
2525
val board = arrayOf(charArrayOf('a', 'b'), charArrayOf('c', 'd'))
26-
val words = arrayOf<String?>("abcb")
26+
val words = arrayOf<String>("abcb")
2727
assertThat(Solution().findWords(board, words), equalTo(emptyList()))
2828
}
2929
}

src/test/kotlin/g1101_1200/s1145_binary_tree_coloring_game/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import org.junit.jupiter.api.Test
88
internal class SolutionTest {
99
@Test
1010
fun btreeGameWinningMove() {
11-
val root = TreeNode.create(mutableListOf<Int?>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
11+
val root = TreeNode.create(mutableListOf<Int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
1212
assertThat(Solution().btreeGameWinningMove(root, 11, 3), equalTo(true))
1313
}
1414

1515
@Test
1616
fun btreeGameWinningMove2() {
17-
val root = TreeNode.create(mutableListOf<Int?>(1, 2, 3))
17+
val root = TreeNode.create(mutableListOf<Int>(1, 2, 3))
1818
assertThat(Solution().btreeGameWinningMove(root, 3, 1), equalTo(false))
1919
}
2020
}

src/test/kotlin/g2401_2500/s2468_split_message_based_on_limit/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class SolutionTest {
1010
assertThat(
1111
Solution().splitMessage("this is really a very awesome message", 9),
1212
equalTo(
13-
arrayOf<String?>(
13+
arrayOf<String>(
1414
"thi<1/14>",
1515
"s i<2/14>",
1616
"s r<3/14>",
@@ -34,7 +34,7 @@ internal class SolutionTest {
3434
fun splitMessage2() {
3535
assertThat(
3636
Solution().splitMessage("short message", 15),
37-
equalTo(arrayOf<String?>("short mess<1/2>", "age<2/2>")),
37+
equalTo(arrayOf<String>("short mess<1/2>", "age<2/2>")),
3838
)
3939
}
4040
}

src/test/kotlin/g2801_2900/s2809_minimum_time_to_make_array_sum_at_most_x/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ internal class SolutionTest {
88
@Test
99
fun minimumTime() {
1010
assertThat(
11-
Solution().minimumTime(mutableListOf<Int?>(1, 2, 3), mutableListOf<Int?>(1, 2, 3), 4),
11+
Solution().minimumTime(mutableListOf<Int>(1, 2, 3), mutableListOf<Int>(1, 2, 3), 4),
1212
equalTo(3),
1313
)
1414
}
1515

1616
@Test
1717
fun minimumTime2() {
1818
assertThat(
19-
Solution().minimumTime(mutableListOf<Int?>(1, 2, 3), mutableListOf<Int?>(3, 3, 3), 4),
19+
Solution().minimumTime(mutableListOf<Int>(1, 2, 3), mutableListOf<Int>(3, 3, 3), 4),
2020
equalTo(-1),
2121
)
2222
}

src/test/kotlin/g2801_2900/s2818_apply_operations_to_maximize_score/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ internal class SolutionTest {
88
@Test
99
fun maximumScore() {
1010
assertThat(
11-
Solution().maximumScore(mutableListOf<Int?>(8, 3, 9, 3, 8), 2),
11+
Solution().maximumScore(mutableListOf<Int>(8, 3, 9, 3, 8), 2),
1212
equalTo(81),
1313
)
1414
}
1515

1616
@Test
1717
fun maximumScore2() {
1818
assertThat(
19-
Solution().maximumScore(mutableListOf<Int?>(19, 12, 14, 6, 10, 18), 3),
19+
Solution().maximumScore(mutableListOf<Int>(19, 12, 14, 6, 10, 18), 3),
2020
equalTo(4788),
2121
)
2222
}

src/test/kotlin/g2901_3000/s2966_divide_array_into_arrays_with_max_difference/SolutionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class SolutionTest {
99
fun divideArray() {
1010
assertThat(
1111
Solution().divideArray(intArrayOf(1, 3, 4, 8, 7, 9, 3, 5, 1), 2),
12-
equalTo(arrayOf<IntArray?>(intArrayOf(1, 1, 3), intArrayOf(3, 4, 5), intArrayOf(7, 8, 9))),
12+
equalTo(arrayOf<IntArray>(intArrayOf(1, 1, 3), intArrayOf(3, 4, 5), intArrayOf(7, 8, 9))),
1313
)
1414
}
1515

src/test/kotlin/g3001_3100/s3076_shortest_uncommon_substring_in_an_array/SolutionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ internal class SolutionTest {
99
fun shortestSubstrings() {
1010
assertThat(
1111
Solution().shortestSubstrings(arrayOf("cab", "ad", "bad", "c")),
12-
equalTo(arrayOf<String?>("ab", "", "ba", "")),
12+
equalTo(arrayOf<String>("ab", "", "ba", "")),
1313
)
1414
}
1515

1616
@Test
1717
fun shortestSubstrings2() {
1818
assertThat(
1919
Solution().shortestSubstrings(arrayOf("abc", "bcd", "abcd")),
20-
equalTo(arrayOf<String?>("", "", "abcd")),
20+
equalTo(arrayOf<String>("", "", "abcd")),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3280_convert_date_to_binary/SolutionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun convertDateToBinary() {
10-
assertThat<String?>(
10+
assertThat<String>(
1111
Solution().convertDateToBinary("2080-02-29"),
12-
equalTo<String?>("100000100000-10-11101"),
12+
equalTo<String>("100000100000-10-11101"),
1313
)
1414
}
1515

1616
@Test
1717
fun convertDateToBinary2() {
18-
assertThat<String?>(
18+
assertThat<String>(
1919
Solution().convertDateToBinary("1900-01-01"),
20-
equalTo<String?>("11101101100-1-1"),
20+
equalTo<String>("11101101100-1-1"),
2121
)
2222
}
2323
}

src/test/kotlin/g3201_3300/s3281_maximize_score_of_numbers_in_ranges/SolutionTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun maxPossibleScore() {
10-
assertThat<Int?>(
10+
assertThat<Int>(
1111
Solution().maxPossibleScore(intArrayOf(6, 0, 3), 2),
12-
equalTo<Int?>(4),
12+
equalTo<Int>(4),
1313
)
1414
}
1515

1616
@Test
1717
fun maxPossibleScore2() {
18-
assertThat<Int?>(
18+
assertThat<Int>(
1919
Solution().maxPossibleScore(intArrayOf(2, 6, 13, 13), 5),
20-
equalTo<Int?>(5),
20+
equalTo<Int>(5),
2121
)
2222
}
2323
}

0 commit comments

Comments
 (0)