@@ -10,21 +10,45 @@ func TestSolution(t *testing.T) {
10
10
// 测试用例
11
11
cases := []struct {
12
12
name string
13
- inputs bool
14
- expect bool
13
+ input1 string
14
+ input2 string
15
+ expect int
15
16
}{
16
- {"TestCase" , true , true },
17
- {"TestCase" , true , true },
18
- {"TestCase" , false , false },
17
+ {"TestCase" , "aA" , "aAAbbbb" , 3 },
18
+ {"TestCase" , "z" , "ZZ" , 0 },
19
19
}
20
20
21
21
// 开始测试
22
22
for i , c := range cases {
23
23
t .Run (c .name + " " + strconv .Itoa (i ), func (t * testing.T ) {
24
- got := Solution (c .inputs )
24
+ got := numJewelsInStones (c .input1 , c . input2 )
25
25
if ! reflect .DeepEqual (got , c .expect ) {
26
- t .Fatalf ("expected: %v, but got: %v, with inputs: %v" ,
27
- c .expect , got , c .inputs )
26
+ t .Fatalf ("expected: %v, but got: %v, with input1: %v input2: %v" ,
27
+ c .expect , got , c .input1 , c .input1 )
28
+ }
29
+ })
30
+ }
31
+ }
32
+
33
+ func TestSolution2 (t * testing.T ) {
34
+ // 测试用例
35
+ cases := []struct {
36
+ name string
37
+ input1 string
38
+ input2 string
39
+ expect int
40
+ }{
41
+ {"TestCase" , "aA" , "aAAbbbb" , 3 },
42
+ {"TestCase" , "z" , "ZZ" , 0 },
43
+ }
44
+
45
+ // 开始测试
46
+ for i , c := range cases {
47
+ t .Run (c .name + " " + strconv .Itoa (i ), func (t * testing.T ) {
48
+ got := numJewelsInStones2 (c .input1 , c .input2 )
49
+ if ! reflect .DeepEqual (got , c .expect ) {
50
+ t .Fatalf ("expected: %v, but got: %v, with input1: %v input2: %v" ,
51
+ c .expect , got , c .input1 , c .input1 )
28
52
}
29
53
})
30
54
}
0 commit comments