aboutsummaryrefslogtreecommitdiff
path: root/terminal_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'terminal_test.go')
-rw-r--r--terminal_test.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/terminal_test.go b/terminal_test.go
index bec14bf..b0686ed 100644
--- a/terminal_test.go
+++ b/terminal_test.go
@@ -1,6 +1,9 @@
package main
-import "testing"
+import (
+ "slices"
+ "testing"
+)
// This could be way more extensive, but we're not aiming for perfection.
var tests = []struct {
@@ -68,3 +71,30 @@ Loop:
}
}
}
+
+func TestTerminalUpdateGroups(t *testing.T) {
+ tw := terminalWriter{}
+ collect := func() (have []int) {
+ for _, line := range tw.lines {
+ have = append(have, line.updateGroup)
+ }
+ return
+ }
+
+ // 0: A 0 0 0
+ // 1: B X 1 1 1
+ // 2: C Y 1 2 1 1
+ // 3: Z 2 3 2
+ // 4: 3 4
+ tw.Write([]byte("A\nB\nC\x1b[FX\nY\nZ"))
+ have, want := collect(), []int{0, 1, 1, 3}
+ if !slices.Equal(want, have) {
+ t.Errorf("update groups: %+v; want: %+v", have, want)
+ }
+
+ tw.Write([]byte("\x1b[F1\n2\n3"))
+ have, want = collect(), []int{0, 1, 1, 2, 4}
+ if !slices.Equal(want, have) {
+ t.Errorf("update groups: %+v; want: %+v", have, want)
+ }
+}