Debian Codegraph @

build/intersect_test.go

raw symbols SCIP
1 package build
2
3 import (
4 "fmt"
5 "testing"
6 )
7
8 func TestIntersect(t *testing.T) {
9 res := Empty(0).AddCost(4).Intersect(Grid(1, 2).AddCost(5))
10 exp := "0 []"
11 if mess, diff := diff(res.String(), exp); diff {
12 t.Errorf("Intersect %s", mess)
13 }
14 Consistent("Intersect1", t, res)
15
16 res = Grid(1, 2).AddCost(4).Intersect(Grid(1, 2).AddCost(5))
17 exp = "2 [{0 1}]"
18 if mess, diff := diff(res.String(), exp); diff {
19 t.Errorf("Intersect %s", mess)
20 }
21 Consistent("Intersect2", t, res)
22
23 res = Grid(2, 2).Intersect(Kn(3).AddCost(8))
24 exp = "3 [{0 1} {0 2}]"
25 if mess, diff := diff(res.String(), exp); diff {
26 t.Errorf("Intersect %s", mess)
27 }
28 Consistent("Intersect3", t, res)
29
30 res = Kn(3).Intersect(Grid(2, 2))
31 exp = "3 [{0 1} {0 2}]"
32 if mess, diff := diff(res.String(), exp); diff {
33 t.Errorf("Intersect %s", mess)
34 }
35 Consistent("Intersect4", t, res)
36
37 for m := 0; m < 5; m++ {
38 for n := 0; n < 5; n++ {
39 res = Kn(m).Intersect(Kn(n))
40 mess := fmt.Sprintf("Kn(%d).Intersect(Kn(%d))", m, n)
41 Consistent(mess, t, res)
42
43 res = Grid(m, n).Intersect(Kn(n))
44 mess = fmt.Sprintf("Grid(%d,%d).Intersect(Kn(%d))", m, n, n)
45 Consistent(mess, t, res)
46 res = Kn(n).Intersect(Grid(m, n))
47 mess = fmt.Sprintf("Kn(%d).Intersect(Grid(%d,%d))", n, m, n)
48 Consistent(mess, t, res)
49
50 km := Kn(m).Keep(func(v, w int) bool {
51 return v != m-1 && w != m-1
52 })
53 res = km.Intersect(Kn(n))
54 Consistent("Intersect", t, res)
55 }
56 }
57 }