build text-entry component
This commit is contained in:
@@ -174,3 +174,66 @@ func TestContainerTwoBoxesPercentageVStack(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewEditableTextLine(t *testing.T) {
|
||||
e := NewEditableTextLine("")
|
||||
e.InsertAtCursor('a')
|
||||
e.InsertAtCursor('b')
|
||||
e.InsertAtCursor('c')
|
||||
if e.text != "abc" {
|
||||
fmt.Printf("expected: 'abc', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.MoveCursor(-1)
|
||||
e.InsertAtCursor('d')
|
||||
if e.text != "abdc" {
|
||||
fmt.Printf("expected: 'abdc', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.MoveCursor(-20)
|
||||
e.InsertAtCursor('e')
|
||||
if e.text != "eabdc" {
|
||||
fmt.Printf("expected: 'eabdc', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.MoveCursor(20)
|
||||
e.InsertAtCursor('f')
|
||||
if e.text != "eabdcf" {
|
||||
fmt.Printf("expected: 'eabdcf', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.MoveCursor(1)
|
||||
e.InsertAtCursor('g')
|
||||
if e.text != "eabdcfg" {
|
||||
fmt.Printf("expected: 'eabdcfg', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.DeleteAtCursor()
|
||||
e.DeleteAtCursor()
|
||||
e.MoveCursor(-1)
|
||||
e.DeleteAtCursor()
|
||||
if e.text != "eabc" {
|
||||
fmt.Printf("expected: 'eabc', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.ResetCursor(false)
|
||||
e.InsertAtCursor('h')
|
||||
e.ResetCursor(true)
|
||||
e.InsertAtCursor('g')
|
||||
if e.text != "geabch" {
|
||||
fmt.Printf("expected: 'geabch', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.SetText("the rain in spain")
|
||||
e.InsertAtCursor('s')
|
||||
if e.text != "the rain in spains" {
|
||||
fmt.Printf("expected: 'the rain in spains', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
e.SetText("")
|
||||
e.InsertAtCursor('s')
|
||||
if e.text != "s" {
|
||||
fmt.Printf("expected: 's', actual: '%+v'", e.text)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user