-
Notifications
You must be signed in to change notification settings - Fork 25
/
assert.go
61 lines (56 loc) · 1.39 KB
/
assert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"image"
"log"
"github.com/as/ui/tag"
)
const debug = 1 ^ 1
func assert(where string, g *Grid) {
if debug == 0 {
return
}
log.Printf("%s: grid %s\n", where, g.Bounds())
for i, c := range g.List {
for j, c2 := range g.List {
if c == c2 {
continue
}
if c.Bounds().Intersect(c2.Bounds()) != image.ZR {
log.Printf("%s: col %v %s intersects col %v %s\n", where, i, c.Bounds(), j, c2.Bounds())
panic("suicide")
}
}
}
if g.Tag.Vis != tag.VisTag {
log.Printf("%v\n", g.Tag.Vis)
// panic("grid tag not vistag") // Put
}
for i, c := range g.List {
if c.(*Col).Tag.Vis != tag.VisTag {
log.Printf("number %d = %v\n", i, g.Tag.Vis)
//panic("col tag not vistag")
}
if !c.Bounds().In(g.Bounds()) {
log.Printf("%s: col %v %s not in grid %s\n", where, i, c.Bounds(), g.Bounds())
// panic("suicide")
}
log.Printf("%s: col %v %s is good\n", where, i, c.Bounds())
{
c, _ := c.(*Col)
if c == nil {
continue
}
for j, t := range c.List {
if !t.Bounds().In(c.Bounds()) {
log.Printf("%s: tag %v %s not in col %v %s\n", where, j, t.Bounds(), i, c.Bounds())
//panic("suicide")
}
if !t.Bounds().In(g.Bounds()) {
log.Printf("%s: tag %v %s not in grid %v %s\n", where, j, t.Bounds(), i, g.Bounds())
//panic("suicide")
}
log.Printf("%s: tag %v %s is good\n", where, j, t.Bounds())
}
}
}
}