|
|
|
@ -13,6 +13,8 @@ const (
|
|
|
|
|
func TestList(t *testing.T) { |
|
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
|
|
|
|
|
|
l := NewList() |
|
|
|
|
if l.GetItemCount() != 0 { |
|
|
|
|
t.Errorf("failed to initialize List: expected item count 0, got %d", l.GetItemCount()) |
|
|
|
@ -20,6 +22,8 @@ func TestList(t *testing.T) {
|
|
|
|
|
t.Errorf("failed to initialize List: expected current item 0, got %d", l.GetCurrentItem()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add item 0
|
|
|
|
|
|
|
|
|
|
l.AddItem(listTextA, listTextB, 'a', nil) |
|
|
|
|
if l.GetItemCount() != 1 { |
|
|
|
|
t.Errorf("failed to update List: expected item count 1, got %d", l.GetItemCount()) |
|
|
|
@ -27,6 +31,8 @@ func TestList(t *testing.T) {
|
|
|
|
|
t.Errorf("failed to update List: expected current item 0, got %d", l.GetCurrentItem()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get item 0 text
|
|
|
|
|
|
|
|
|
|
mainText, secondaryText := l.GetItemText(0) |
|
|
|
|
if mainText != listTextA { |
|
|
|
|
t.Errorf("failed to update List: expected main text %s, got %s", listTextA, mainText) |
|
|
|
@ -34,6 +40,8 @@ func TestList(t *testing.T) {
|
|
|
|
|
t.Errorf("failed to update List: expected secondary text %s, got %s", listTextB, secondaryText) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add item 1
|
|
|
|
|
|
|
|
|
|
l.AddItem(listTextB, listTextC, 'a', nil) |
|
|
|
|
if l.GetItemCount() != 2 { |
|
|
|
|
t.Errorf("failed to update List: expected item count 1, got %v", l.GetItemCount()) |
|
|
|
@ -41,6 +49,8 @@ func TestList(t *testing.T) {
|
|
|
|
|
t.Errorf("failed to update List: expected current item 0, got %v", l.GetCurrentItem()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Get item 1 text
|
|
|
|
|
|
|
|
|
|
mainText, secondaryText = l.GetItemText(1) |
|
|
|
|
if mainText != listTextB { |
|
|
|
|
t.Errorf("failed to update List: expected main text %s, got %s", listTextB, mainText) |
|
|
|
@ -48,6 +58,8 @@ func TestList(t *testing.T) {
|
|
|
|
|
t.Errorf("failed to update List: expected secondary text %s, got %s", listTextC, secondaryText) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Draw
|
|
|
|
|
|
|
|
|
|
app, err := newTestApp(l) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Errorf("failed to initialize Application: %s", err) |
|
|
|
|