diff options
| author | Pietro Gagliardi <[email protected]> | 2014-04-10 20:42:01 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-04-10 20:42:01 -0400 |
| commit | d6abf79932d5c1dc74c52beffd6fb1e6359c04cf (patch) | |
| tree | 903142adc1e84e5b4996e626e40d682d107621f5 /test/main.go | |
| parent | 1c11ef2d9cb18502d272cee63f3ceb1d381c9e8b (diff) | |
Added bounds checking to NewArea() and Area.SetSize() such that an Area must have a valid size.
Diffstat (limited to 'test/main.go')
| -rw-r--r-- | test/main.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/main.go b/test/main.go index f19c655..7397cc6 100644 --- a/test/main.go +++ b/test/main.go @@ -78,6 +78,7 @@ func invalidTest(c *Combobox, l *Listbox, s *Stack, g *Grid) { func() { defer x("Listbox.Delete > len"); l.Delete(c.Len() + 5); panic(nil) }() + // TODO get rid of arg != nil by creating dummy arg if s != nil { func() { defer x("Stack.SetStretchy < 0"); s.SetStretchy(-5); panic(nil) @@ -86,6 +87,7 @@ func invalidTest(c *Combobox, l *Listbox, s *Stack, g *Grid) { defer x("Stack.SetStretchy > len"); s.SetStretchy(5555); panic(nil) }() } + // TODO grid creation checks if g != nil { func() { defer x("Grid.SetFilling x < 0"); g.SetFilling(-5, 0); panic(nil) @@ -112,6 +114,33 @@ func invalidTest(c *Combobox, l *Listbox, s *Stack, g *Grid) { defer x("Grid.SetStretchy y > len"); g.SetStretchy(0, 5555); panic(nil) }() } + ah := &areaHandler{nil} + type at struct { + msg string + x, y int + } + var ats = []at{ + at{"width < 0", -5, 5}, + at{"width == 0", 0, 5}, + at{"height < 0", 5, -5}, + at{"height == 0", 5, 0}, + at{"width/heght < 0", -5, -5}, + at{"width < 0/height == 0", -5, 0}, + at{"width == 0/height < 0", 0, -5}, + at{"width/height == 0", 0, 0}, + } + for _, q := range ats { + func() { + defer x("NewArea() " + q.msg); NewArea(q.x, q.y, ah); panic(nil) + }() + } + // no need to pass this in as an argument since it's handled by the portable code, not by sysData + a := NewArea(50, 50, ah) + for _, q := range ats { + func() { + defer x("Area.SetSize() " + q.msg); a.SetSize(q.x, q.y); panic(nil) + }() + } MsgBox("test", "all working as intended") } |
