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