Skip to content

Commit da7f306

Browse files
committed
Added tests
1 parent c8aa2a4 commit da7f306

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,54 @@
11
package leetcode
22

3-
import "testing"
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/halfrost/LeetCode-Go/structures"
8+
)
9+
10+
type question141 struct {
11+
para141
12+
ans141
13+
}
14+
15+
// para 是参数
16+
// one 代表第一个参数
17+
type para141 struct {
18+
one []int
19+
}
20+
21+
// ans 是答案
22+
// one 代表第一个答案
23+
type ans141 struct {
24+
one bool
25+
}
426

527
func Test_Problem141(t *testing.T) {
28+
29+
qs := []question141{
30+
31+
{
32+
para141{[]int{3, 2, 0, -4}},
33+
ans141{true},
34+
},
35+
36+
{
37+
para141{[]int{1, 2}},
38+
ans141{true},
39+
},
40+
41+
{
42+
para141{[]int{1}},
43+
ans141{false},
44+
},
45+
}
46+
47+
fmt.Printf("------------------------Leetcode Problem 141------------------------\n")
48+
49+
for _, q := range qs {
50+
_, p := q.ans141, q.para141
51+
fmt.Printf("【input】:%v 【output】:%v\n", p, hasCycle(structures.Ints2List(p.one)))
52+
}
53+
fmt.Printf("\n\n\n")
654
}

0 commit comments

Comments
 (0)