Skip to content

Commit 8dfcc91

Browse files
committed
Create possibleBipartition_test.go
1 parent bc17f18 commit 8dfcc91

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package possible_bipartition
2+
3+
import (
4+
"encoding/json"
5+
// "fmt"
6+
"gotest.tools/v3/assert"
7+
"testing"
8+
)
9+
10+
func TestPossibleBipartition(t *testing.T) {
11+
12+
cases := []struct {
13+
n int
14+
dislikes string
15+
result bool
16+
}{
17+
{4, "[[1,2],[1,3],[2,4]]", true},
18+
{3, "[[1,2],[1,3],[2,3]]", false},
19+
{5, "[[1,2],[2,3],[3,4],[4,5],[1,5]]", false},
20+
}
21+
for _, c := range cases {
22+
23+
var d [][]int
24+
var e = json.Unmarshal(([]byte(c.dislikes)), &d)
25+
if e != nil {
26+
panic(e)
27+
}
28+
// fmt.Println(c)
29+
// fmt.Println(d)
30+
assert.Equal(t, c.result, possibleBipartition(c.n, d))
31+
}
32+
}

0 commit comments

Comments
 (0)