Skip to content

Commit e8ae1fe

Browse files
committed
Fixed warnings, added unit tests.
1 parent 50b5e69 commit e8ae1fe

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/main/kotlin/g0001_0100/s0001_two_sum/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package g0001_0100.s0001_two_sum
22

3-
import java.util.*
3+
import java.util.Arrays
44

55
class Solution {
66
fun twoSum(nums: IntArray?, target: Int): IntArray {

src/main/kotlin/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Solution {
99
var maxLen = 0
1010
var curLen = 0
1111
var start = 0
12-
for (i in 0 until s.length) {
12+
for (i in s.indices) {
1313
val cur = s[i]
1414
if (lastIndices[cur.code] < start) {
1515
lastIndices[cur.code] = i

src/test/kotlin/g0001_0100/s0008_string_to_integer_atoi/SolutionTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,24 @@ class SolutionTest {
99
fun myAtoi() {
1010
assertThat(Solution().myAtoi("42"), equalTo(42))
1111
}
12+
13+
@Test
14+
fun myAtoi2() {
15+
assertThat(Solution().myAtoi(" -42"), equalTo(-42))
16+
}
17+
18+
@Test
19+
fun myAtoi3() {
20+
assertThat(Solution().myAtoi("4193 with words"), equalTo(4193))
21+
}
22+
23+
@Test
24+
fun myAtoi4() {
25+
assertThat(Solution().myAtoi("words and 987"), equalTo(0))
26+
}
27+
28+
@Test
29+
fun myAtoi5() {
30+
assertThat(Solution().myAtoi("-91283472332"), equalTo(-2147483648))
31+
}
1232
}

0 commit comments

Comments
 (0)