Skip to content

Commit 56ebca6

Browse files
author
Shuo
authored
Merge pull request #712 from openset/develop
Update: test
2 parents 5bb90bd + 963ebd2 commit 56ebca6

File tree

219 files changed

+3575
-3575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+3575
-3575
lines changed

internal/leetcode/question_data.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,22 @@ const testTpl = `package {{packageName}}
332332
333333
import "testing"
334334
335-
type caseType struct {
336-
input int
337-
expected int
335+
type testType struct {
336+
in int
337+
want int
338338
}
339339
340340
func Test{{funcName}}(t *testing.T) {
341-
tests := [...]caseType{
341+
tests := [...]testType{
342342
{
343-
input: 0,
344-
expected: 0,
343+
in: 0,
344+
want: 0,
345345
},
346346
}
347-
for _, tc := range tests {
348-
output := 0
349-
if output != tc.expected {
350-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
347+
for _, tt := range tests {
348+
got := 0
349+
if got != tt.want {
350+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
351351
}
352352
}
353353
}

problems/01-matrix/01_matrix_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ import (
55
"testing"
66
)
77

8-
type caseType struct {
9-
input [][]int
10-
expected [][]int
8+
type testType struct {
9+
in [][]int
10+
want [][]int
1111
}
1212

1313
func TestUpdateMatrix(t *testing.T) {
14-
tests := [...]caseType{
14+
tests := [...]testType{
1515
{
16-
input: [][]int{
16+
in: [][]int{
1717
{0, 0, 0},
1818
{0, 1, 0},
1919
{0, 0, 0},
2020
},
21-
expected: [][]int{
21+
want: [][]int{
2222
{0, 0, 0},
2323
{0, 1, 0},
2424
{0, 0, 0},
2525
},
2626
},
2727
{
28-
input: [][]int{
28+
in: [][]int{
2929
{0, 0, 0},
3030
{0, 1, 0},
3131
{1, 1, 1},
3232
},
33-
expected: [][]int{
33+
want: [][]int{
3434
{0, 0, 0},
3535
{0, 1, 0},
3636
{1, 2, 1},
3737
},
3838
},
3939
}
40-
for _, tc := range tests {
41-
output := updateMatrix(tc.input)
42-
if !reflect.DeepEqual(output, tc.expected) {
43-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
40+
for _, tt := range tests {
41+
got := updateMatrix(tt.in)
42+
if !reflect.DeepEqual(got, tt.want) {
43+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
4444
}
4545
}
4646
}

problems/1-bit-and-2-bit-characters/1_bit_and_2_bit_characters_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ package problem717
22

33
import "testing"
44

5-
type caseType struct {
6-
input []int
7-
expected bool
5+
type testType struct {
6+
in []int
7+
want bool
88
}
99

1010
func TestIsOneBitCharacter(t *testing.T) {
11-
tests := [...]caseType{
11+
tests := [...]testType{
1212
{
13-
input: []int{1, 0, 0},
14-
expected: true,
13+
in: []int{1, 0, 0},
14+
want: true,
1515
},
1616
{
17-
input: []int{1, 1, 1, 0},
18-
expected: false,
17+
in: []int{1, 1, 1, 0},
18+
want: false,
1919
},
2020
}
21-
for _, tc := range tests {
22-
output := isOneBitCharacter(tc.input)
23-
if output != tc.expected {
24-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
21+
for _, tt := range tests {
22+
got := isOneBitCharacter(tt.in)
23+
if got != tt.want {
24+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
2525
}
2626
}
2727
}

problems/132-pattern/132_pattern_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ package problem456
22

33
import "testing"
44

5-
type caseType struct {
6-
input []int
7-
expected bool
5+
type testType struct {
6+
in []int
7+
want bool
88
}
99

1010
func TestFind132pattern(t *testing.T) {
11-
tests := [...]caseType{
11+
tests := [...]testType{
1212
{
13-
input: []int{1, 2, 3, 4},
14-
expected: false,
13+
in: []int{1, 2, 3, 4},
14+
want: false,
1515
},
1616
{
17-
input: []int{3, 1, 4, 2},
18-
expected: true,
17+
in: []int{3, 1, 4, 2},
18+
want: true,
1919
},
2020
{
21-
input: []int{-1, 3, 2, 0},
22-
expected: true,
21+
in: []int{-1, 3, 2, 0},
22+
want: true,
2323
},
2424
}
25-
for _, tc := range tests {
26-
output := find132pattern(tc.input)
27-
if output != tc.expected {
28-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
25+
for _, tt := range tests {
26+
got := find132pattern(tt.in)
27+
if got != tt.want {
28+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
2929
}
3030
}
3131
}

problems/2-keys-keyboard/2_keys_keyboard_test.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@ package problem650
22

33
import "testing"
44

5-
type caseType struct {
6-
input int
7-
expected int
5+
type testType struct {
6+
in int
7+
want int
88
}
99

1010
func TestMinSteps(t *testing.T) {
11-
tests := [...]caseType{
11+
tests := [...]testType{
1212
{
13-
input: 1,
14-
expected: 0,
13+
in: 1,
14+
want: 0,
1515
},
1616
{
17-
input: 3,
18-
expected: 3,
17+
in: 3,
18+
want: 3,
1919
},
2020
{
21-
input: 30,
22-
expected: 10,
21+
in: 30,
22+
want: 10,
2323
},
2424
{
25-
input: 97,
26-
expected: 97,
25+
in: 97,
26+
want: 97,
2727
},
2828
}
29-
for _, tc := range tests {
30-
output := minSteps(tc.input)
31-
if output != tc.expected {
32-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
29+
for _, tt := range tests {
30+
got := minSteps(tt.in)
31+
if got != tt.want {
32+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
3333
}
3434
}
3535
}

problems/24-game/24_game_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ package problem679
22

33
import "testing"
44

5-
type caseType struct {
6-
input []int
7-
expected bool
5+
type testType struct {
6+
in []int
7+
want bool
88
}
99

1010
func TestJudgePoint24(t *testing.T) {
11-
tests := [...]caseType{
11+
tests := [...]testType{
1212
{
13-
input: []int{4, 1, 8, 7},
14-
expected: true,
13+
in: []int{4, 1, 8, 7},
14+
want: true,
1515
},
1616
{
17-
input: []int{1, 2, 1, 2},
18-
expected: false,
17+
in: []int{1, 2, 1, 2},
18+
want: false,
1919
},
2020
}
21-
for _, tc := range tests {
22-
output := judgePoint24(tc.input)
23-
if output != tc.expected {
24-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
21+
for _, tt := range tests {
22+
got := judgePoint24(tt.in)
23+
if got != tt.want {
24+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
2525
}
2626
}
2727
}

problems/3sum-closest/3sum_closest_test.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,44 @@ package problem16
22

33
import "testing"
44

5-
type caseType struct {
6-
input []int
7-
target int
8-
expected int
5+
type testType struct {
6+
in []int
7+
target int
8+
want int
99
}
1010

1111
func TestThreeSumClosest(t *testing.T) {
12-
tests := [...]caseType{
12+
tests := [...]testType{
1313
{
14-
input: []int{-1, 2, 1, -4},
15-
target: 1,
16-
expected: 2,
14+
in: []int{-1, 2, 1, -4},
15+
target: 1,
16+
want: 2,
1717
},
1818
{
19-
input: []int{-1, 0, 1, 2, -1, -4},
20-
target: 1,
21-
expected: 1,
19+
in: []int{-1, 0, 1, 2, -1, -4},
20+
target: 1,
21+
want: 1,
2222
},
2323
{
24-
input: []int{0, 0, 0, 0},
25-
target: 1,
26-
expected: 0,
24+
in: []int{0, 0, 0, 0},
25+
target: 1,
26+
want: 0,
2727
},
2828
{
29-
input: []int{-2, 0, 0, 2, 2, 2},
30-
target: 2,
31-
expected: 2,
29+
in: []int{-2, 0, 0, 2, 2, 2},
30+
target: 2,
31+
want: 2,
3232
},
3333
{
34-
input: []int{-2, 0, 0, 2, 2, 2, 2},
35-
target: 1,
36-
expected: 0,
34+
in: []int{-2, 0, 0, 2, 2, 2, 2},
35+
target: 1,
36+
want: 0,
3737
},
3838
}
39-
for _, tc := range tests {
40-
output := threeSumClosest(tc.input, tc.target)
41-
if output != tc.expected {
42-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
39+
for _, tt := range tests {
40+
got := threeSumClosest(tt.in, tt.target)
41+
if got != tt.want {
42+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
4343
}
4444
}
4545
}

problems/3sum/3sum_test.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@ import (
55
"testing"
66
)
77

8-
type caseType struct {
9-
input []int
10-
expected [][]int
8+
type testType struct {
9+
in []int
10+
want [][]int
1111
}
1212

1313
func TestThreeSum(t *testing.T) {
14-
tests := [...]caseType{
14+
tests := [...]testType{
1515
{
16-
input: []int{-1, 0, 1, 2, -1, -4},
17-
expected: [][]int{
16+
in: []int{-1, 0, 1, 2, -1, -4},
17+
want: [][]int{
1818
{-1, -1, 2},
1919
{-1, 0, 1},
2020
},
2121
},
2222
{
23-
input: []int{0, 0, 0, 0},
24-
expected: [][]int{
23+
in: []int{0, 0, 0, 0},
24+
want: [][]int{
2525
{0, 0, 0},
2626
},
2727
},
2828
{
29-
input: []int{-2, 0, 0, 2, 2, 2},
30-
expected: [][]int{
29+
in: []int{-2, 0, 0, 2, 2, 2},
30+
want: [][]int{
3131
{-2, 0, 2},
3232
},
3333
},
3434
{
35-
input: []int{-2, 0, 0, 2, 2, 2, 2},
36-
expected: [][]int{
35+
in: []int{-2, 0, 0, 2, 2, 2, 2},
36+
want: [][]int{
3737
{-2, 0, 2},
3838
},
3939
},
4040
}
41-
for _, tc := range tests {
42-
output := threeSum(tc.input)
43-
if !reflect.DeepEqual(output, tc.expected) {
44-
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
41+
for _, tt := range tests {
42+
got := threeSum(tt.in)
43+
if !reflect.DeepEqual(got, tt.want) {
44+
t.Fatalf("in: %v, got: %v, want: %v", tt.in, got, tt.want)
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)