From cdd535cc717201bb9814e798b86efe65b326dd98 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 11 Mar 2014 17:37:04 -0400 Subject: 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. --- stack.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'stack.go') diff --git a/stack.go b/stack.go index cb65bb5..2ead5dc 100644 --- a/stack.go +++ b/stack.go @@ -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 { -- cgit v1.2.3