diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-11 17:37:04 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-11 17:37:04 -0400 |
| commit | cdd535cc717201bb9814e798b86efe65b326dd98 (patch) | |
| tree | 441201378ca10f318e3697429777a1fec40642fc /stack.go | |
| parent | 92fb9efce9d9f84e06f574243218e3c6d7478d18 (diff) | |
Made Stack.SetStretchy() panic on invalid index, ending that group of functions. Also added the tests for those functions who did not have tests already written.
Diffstat (limited to 'stack.go')
| -rw-r--r-- | stack.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -48,7 +48,7 @@ func NewVerticalStack(controls ...Control) *Stack { } // SetStretchy marks a control in a Stack as stretchy. This cannot be called once the Window containing the Stack has been opened. -// (TODO action on invalid index) +// It panics if index is out of range. func (s *Stack) SetStretchy(index int) { s.lock.Lock() defer s.lock.Unlock() @@ -56,7 +56,10 @@ func (s *Stack) SetStretchy(index int) { if s.created { panic("call to Stack.SetStretchy() after Stack has been created") } - s.stretchy[index] = true // TODO explicitly check for index out of bounds? + if index < 0 || index > len(s.stretchy) { + panic(fmt.Errorf("index %d out of range in Stack.SetStretchy()", index)) + } + s.stretchy[index] = true } func (s *Stack) make(window *sysData) error { |
