Terminal-based user interface toolkit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
889 B

package cview
import (
"testing"
)
const (
testButtonLabelA = "Hello, world!"
testButtonLabelB = "Goodnight, moon!"
)
func TestButton(t *testing.T) {
t.Parallel()
// Initialize
b := NewButton(testButtonLabelA)
if b.GetLabel() != testButtonLabelA {
t.Errorf("failed to initialize Button: incorrect label: expected %s, got %s", testButtonLabelA, b.GetLabel())
}
// Set label
b.SetLabel(testButtonLabelB)
if b.GetLabel() != testButtonLabelB {
t.Errorf("failed to update Button: incorrect label: expected %s, got %s", testButtonLabelB, b.GetLabel())
}
b.SetLabel(testButtonLabelA)
if b.GetLabel() != testButtonLabelA {
t.Errorf("failed to update Button: incorrect label: expected %s, got %s", testButtonLabelA, b.GetLabel())
}
// Draw
app, err := newTestApp(b)
if err != nil {
t.Errorf("failed to initialize Application: %s", err)
}
b.Draw(app.screen)
}