Skip to content

Commit 6182cba

Browse files
committed
nvim: add WindowCursor and SetWindowCursor testcases
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 3d10e03 commit 6182cba

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

nvim/api_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,32 @@ func testWindow(v *Nvim) func(*testing.T) {
10261026
}
10271027
})
10281028
})
1029+
1030+
t.Run("WindowCursor", func(t *testing.T) {
1031+
wantLine := []byte("hello world")
1032+
if err := v.SetCurrentLine(wantLine); err != nil {
1033+
t.Fatal(err)
1034+
}
1035+
t.Cleanup(func() {
1036+
if err := v.DeleteCurrentLine(); err != nil {
1037+
t.Fatal(err)
1038+
}
1039+
})
1040+
1041+
wantPos := [2]int{1, 5}
1042+
if err := v.SetWindowCursor(Window(0), wantPos); err != nil {
1043+
t.Fatal(err)
1044+
}
1045+
1046+
gotPos, err := v.WindowCursor(Window(0))
1047+
if err != nil {
1048+
t.Fatal(err)
1049+
}
1050+
1051+
if wantPos != gotPos {
1052+
t.Fatalf("want %#v position buf got %#v", wantPos, gotPos)
1053+
}
1054+
})
10291055
})
10301056

10311057
t.Run("Batch", func(t *testing.T) {
@@ -1152,6 +1178,36 @@ func testWindow(v *Nvim) func(*testing.T) {
11521178
}
11531179
})
11541180
})
1181+
1182+
t.Run("WindowCursor", func(t *testing.T) {
1183+
wantLine := []byte("hello world")
1184+
b.SetCurrentLine(wantLine)
1185+
if err := b.Execute(); err != nil {
1186+
t.Fatal(err)
1187+
}
1188+
t.Cleanup(func() {
1189+
b.DeleteCurrentLine()
1190+
if err := b.Execute(); err != nil {
1191+
t.Fatal(err)
1192+
}
1193+
})
1194+
1195+
wantPos := [2]int{1, 5}
1196+
b.SetWindowCursor(Window(0), wantPos)
1197+
if err := b.Execute(); err != nil {
1198+
t.Fatal(err)
1199+
}
1200+
1201+
var gotPos [2]int
1202+
b.WindowCursor(Window(0), &gotPos)
1203+
if err := b.Execute(); err != nil {
1204+
t.Fatal(err)
1205+
}
1206+
1207+
if wantPos != gotPos {
1208+
t.Fatalf("want %#v position buf got %#v", wantPos, gotPos)
1209+
}
1210+
})
11551211
})
11561212
}
11571213
}

0 commit comments

Comments
 (0)