Skip to content

Commit dc0b2aa

Browse files
committed
Added tests
1 parent b6cbefb commit dc0b2aa

File tree

3 files changed

+104
-20
lines changed

3 files changed

+104
-20
lines changed

src/test/kotlin/g3601_3700/s3658_gcd_of_odd_and_even_sums/SolutionTest.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,26 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun gcdOfOddEvenSums() {
10-
assertThat<Int>(Solution().gcdOfOddEvenSums(4), equalTo<Int>(4))
10+
assertThat(Solution().gcdOfOddEvenSums(4), equalTo(4))
1111
}
1212

1313
@Test
1414
fun gcdOfOddEvenSums2() {
15-
assertThat<Int>(Solution().gcdOfOddEvenSums(5), equalTo<Int>(5))
15+
assertThat(Solution().gcdOfOddEvenSums(5), equalTo(5))
16+
}
17+
18+
@Test
19+
fun gcdOfOddEvenSums3() {
20+
assertThat(Solution().gcdOfOddEvenSums(42), equalTo(42))
21+
}
22+
23+
@Test
24+
fun gcdOfOddEvenSums4() {
25+
assertThat(Solution().gcdOfOddEvenSums(-42), equalTo(42))
26+
}
27+
28+
@Test
29+
fun gcdOfOddEvenSums5() {
30+
assertThat(Solution().gcdOfOddEvenSums(0), equalTo(0))
1631
}
1732
}

src/test/kotlin/g3601_3700/s3659_partition_array_into_k_distinct_groups/SolutionTest.kt

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,46 @@ import org.junit.jupiter.api.Test
77
internal class SolutionTest {
88
@Test
99
fun partitionArray() {
10-
assertThat<Boolean>(
11-
Solution().partitionArray(intArrayOf(1, 2, 3, 4), 2),
12-
equalTo<Boolean>(true),
13-
)
10+
assertThat(Solution().partitionArray(intArrayOf(1, 2, 3, 4), 2), equalTo(true))
1411
}
1512

1613
@Test
1714
fun partitionArray2() {
18-
assertThat<Boolean>(
19-
Solution().partitionArray(intArrayOf(3, 5, 2, 2), 2),
20-
equalTo<Boolean>(true),
21-
)
15+
assertThat(Solution().partitionArray(intArrayOf(3, 5, 2, 2), 2), equalTo(true))
2216
}
2317

2418
@Test
2519
fun partitionArray3() {
26-
assertThat<Boolean>(
27-
Solution().partitionArray(intArrayOf(1, 5, 2, 3), 3),
28-
equalTo<Boolean>(false),
29-
)
20+
assertThat(Solution().partitionArray(intArrayOf(1, 5, 2, 3), 3), equalTo(false))
21+
}
22+
23+
@Test
24+
fun partitionArray4() {
25+
val nums = intArrayOf(1, 2, 3, 4, 5)
26+
assertThat(Solution().partitionArray(nums, 2), equalTo(false))
27+
}
28+
29+
@Test
30+
fun partitionArray5() {
31+
val nums = intArrayOf(1, 2, 1, 2)
32+
assertThat(Solution().partitionArray(nums, 2), equalTo(true))
33+
}
34+
35+
@Test
36+
fun partitionArray6() {
37+
val nums = intArrayOf(1, 1, 1, 2)
38+
assertThat(Solution().partitionArray(nums, 2), equalTo(false))
39+
}
40+
41+
@Test
42+
fun partitionArray7() {
43+
val nums = intArrayOf(7)
44+
assertThat(Solution().partitionArray(nums, 1), equalTo(true))
45+
}
46+
47+
@Test
48+
fun partitionArray8() {
49+
val nums = intArrayOf(5, 5, 5, 5, 5, 5)
50+
assertThat(Solution().partitionArray(nums, 3), equalTo(false))
3051
}
3152
}

src/test/kotlin/g3601_3700/s3661_maximum_walls_destroyed_by_robots/SolutionTest.kt

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

1616
@Test
1717
fun maxWalls2() {
18-
assertThat<Int>(
18+
assertThat(
1919
Solution().maxWalls(intArrayOf(10, 2), intArrayOf(5, 1), intArrayOf(5, 2, 7)),
20-
equalTo<Int>(3),
20+
equalTo(3),
2121
)
2222
}
2323

2424
@Test
2525
fun maxWalls3() {
26-
assertThat<Int>(
26+
assertThat(
2727
Solution().maxWalls(intArrayOf(1, 2), intArrayOf(100, 1), intArrayOf(10)),
28-
equalTo<Int>(0),
28+
equalTo(0),
2929
)
3030
}
31+
32+
@Test
33+
fun maxWalls4() {
34+
val robots = intArrayOf(5)
35+
val distance = intArrayOf(3)
36+
val walls = intArrayOf()
37+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(0))
38+
}
39+
40+
@Test
41+
fun maxWalls5() {
42+
val robots = intArrayOf(5)
43+
val distance = intArrayOf(3)
44+
val walls = intArrayOf(2, 4, 5, 6, 8)
45+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(3))
46+
}
47+
48+
@Test
49+
fun maxWalls6() {
50+
val robots = intArrayOf(10)
51+
val distance = intArrayOf(2)
52+
val walls = intArrayOf(7, 8, 9, 10, 11, 13)
53+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(3))
54+
}
55+
56+
@Test
57+
fun maxWalls7() {
58+
val robots = intArrayOf(5, 15)
59+
val distance = intArrayOf(2, 2)
60+
val walls = intArrayOf(4, 5, 6, 14, 15, 16)
61+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(4))
62+
}
63+
64+
@Test
65+
fun maxWalls8() {
66+
val robots = intArrayOf(5, 8)
67+
val distance = intArrayOf(5, 5)
68+
val walls = intArrayOf(2, 4, 5, 6, 7, 8, 9, 10)
69+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(6))
70+
}
71+
72+
@Test
73+
fun maxWalls9() {
74+
val robots = intArrayOf(3, 10, 20)
75+
val distance = intArrayOf(2, 3, 4)
76+
val walls = intArrayOf(1, 2, 3, 4, 5, 8, 10, 12, 17, 19, 20, 22)
77+
assertThat(Solution().maxWalls(robots, distance, walls), equalTo(8))
78+
}
3179
}

0 commit comments

Comments
 (0)