Added tests

This commit is contained in:
Breno Baptista
2021-07-17 00:46:00 -03:00
parent c8aa2a477e
commit da7f306dcb

View File

@ -1,6 +1,54 @@
package leetcode
import "testing"
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question141 struct {
para141
ans141
}
// para 是参数
// one 代表第一个参数
type para141 struct {
one []int
}
// ans 是答案
// one 代表第一个答案
type ans141 struct {
one bool
}
func Test_Problem141(t *testing.T) {
qs := []question141{
{
para141{[]int{3, 2, 0, -4}},
ans141{true},
},
{
para141{[]int{1, 2}},
ans141{true},
},
{
para141{[]int{1}},
ans141{false},
},
}
fmt.Printf("------------------------Leetcode Problem 141------------------------\n")
for _, q := range qs {
_, p := q.ans141, q.para141
fmt.Printf("【input】:%v 【output】:%v\n", p, hasCycle(structures.Ints2List(p.one)))
}
fmt.Printf("\n\n\n")
}