2021-03-30 19:37:02 -04:00
|
|
|
package editor
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestNewRow(t *testing.T) {
|
|
|
|
str := "abcdefg"
|
2021-03-31 14:32:43 -04:00
|
|
|
row := newRow(str)
|
2021-03-30 19:37:02 -04:00
|
|
|
|
|
|
|
got := string(row.chars)
|
|
|
|
want := str
|
|
|
|
|
|
|
|
if got != want {
|
|
|
|
t.Errorf("Row chars not equal to original string. Row: %q, String: %q", row, str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRowSize(t *testing.T) {
|
|
|
|
str := "abcdefg"
|
2021-03-31 14:32:43 -04:00
|
|
|
row := newRow(str)
|
2021-03-30 19:37:02 -04:00
|
|
|
|
2021-03-31 14:32:43 -04:00
|
|
|
got := row.size()
|
2021-03-30 19:37:02 -04:00
|
|
|
want := 7
|
|
|
|
|
|
|
|
if got != want {
|
|
|
|
t.Errorf("Row size not equal to number of runes in original string")
|
|
|
|
}
|
|
|
|
}
|
2021-03-31 19:17:04 -04:00
|
|
|
|
|
|
|
func TestRenderSize(t *testing.T) {
|
|
|
|
str := "\tabcdefg"
|
|
|
|
row := newRow(str)
|
|
|
|
row.update()
|
|
|
|
|
|
|
|
got := row.rSize()
|
|
|
|
want := 11
|
|
|
|
|
|
|
|
if got != want {
|
|
|
|
t.Errorf("Row rsize not equal to number of runes in original string")
|
|
|
|
}
|
|
|
|
}
|