Skip to content

Commit 609e472

Browse files
committed
fix: update test coverage
1 parent 3febc6c commit 609e472

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Diff for: solution/1-99/0001.two-sum/solution_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ func TestTwoSum(t *testing.T) {
1010
nums := []int{1, 2, 3}
1111
target := 3
1212
result := []int{0, 1}
13-
1413
fmt.Printf("nums = %v target = %v result = %v\n", nums, target, twoSum(nums, target))
1514
if ret := twoSum(nums, target); ret[0] != result[0] && ret[1] != result[1] {
1615
t.Fatalf("case fails: %v\n", ret)
@@ -19,9 +18,15 @@ func TestTwoSum(t *testing.T) {
1918
nums = []int{1, 10, 20, 30}
2019
target = 30
2120
result = []int{1, 2}
22-
2321
fmt.Printf("nums = %v target = %v result = %v\n", nums, target, twoSum(nums, target))
2422
if ret := twoSum(nums, target); ret[0] != result[0] && ret[1] != result[1] {
2523
t.Fatalf("case fails: %v\n", ret)
2624
}
25+
26+
nums = []int{}
27+
target = 0
28+
fmt.Printf("nums = %v target = %v result = %v\n", nums, target, twoSum(nums, target))
29+
if ret := twoSum(nums, target); len(ret) != 0 {
30+
t.Fatalf("case fails: %v\n", ret)
31+
}
2732
}

Diff for: solution/1-99/0009.palindrome-number/solution_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ func TestIsPalindrome(t *testing.T) {
1010
var x int
1111
var ret bool = true
1212

13+
x = -1
14+
fmt.Printf("x = %v ret = %v\n", x, isPalindrome(x))
15+
if isPalindrome(x) == ret {
16+
t.Fatalf("case fails: %v\n", ret)
17+
}
18+
1319
x = 121
1420
fmt.Printf("x = %v ret = %v\n", x, isPalindrome(x))
1521
if isPalindrome(x) != ret {

Diff for: solution/1-99/0026.remove-duplicates-from-sorted-array/solution_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ func TestRemoveDuplicates(t *testing.T) {
1818
if removeDuplicates(nums2) != ret {
1919
t.Fatalf("case fails: %v\n", ret)
2020
}
21+
22+
nums3 := []int{}
23+
ret = 0
24+
if removeDuplicates(nums3) != ret {
25+
t.Fatalf("case fails: %v\n", ret)
26+
}
2127
}

0 commit comments

Comments
 (0)