2021-03-31 19:17:04 -04:00
|
|
|
package editor
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
2021-04-02 15:36:43 -04:00
|
|
|
e := NewEditor()
|
2021-03-31 19:17:04 -04:00
|
|
|
|
|
|
|
if e == nil {
|
|
|
|
t.Errorf("Failed to create editor")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-01 18:51:52 -04:00
|
|
|
func TestInsertChar(t *testing.T) {
|
2021-04-02 15:36:43 -04:00
|
|
|
e := NewEditor()
|
2021-04-01 18:51:52 -04:00
|
|
|
e.insertChar('q')
|
|
|
|
|
2021-04-07 16:33:00 -04:00
|
|
|
if e.doc.RowCount() != 1 {
|
2021-04-01 18:51:52 -04:00
|
|
|
t.Errorf("A row was not created when the character was inserted")
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:33:00 -04:00
|
|
|
row := e.doc.GetRow(0)
|
2021-04-02 14:52:44 -04:00
|
|
|
if row.Size() != 1 {
|
2021-04-01 18:51:52 -04:00
|
|
|
t.Errorf("Failed to add character to row. Row: %v", row)
|
|
|
|
}
|
2021-04-01 20:26:40 -04:00
|
|
|
}
|