Skip to content

Commit 45e74ee

Browse files
committed
nvim: add TabpageVar, SetTabpageVar and DeleteTabpageVar testcases
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent dee919e commit 45e74ee

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

nvim/api_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,30 @@ func testTabpage(v *Nvim) func(*testing.T) {
15001500
t.Fatalf("expected valid but got %t", valid)
15011501
}
15021502
})
1503+
1504+
t.Run("TabpageVar", func(t *testing.T) {
1505+
wantValue := []int{1, 2}
1506+
if err := v.SetTabpageVar(Tabpage(0), "lua", wantValue); err != nil {
1507+
t.Fatal(err)
1508+
}
1509+
1510+
var gotValue []int
1511+
if err := v.TabpageVar(Tabpage(0), "lua", &gotValue); err != nil {
1512+
t.Fatal(err)
1513+
}
1514+
1515+
if !reflect.DeepEqual(gotValue, wantValue) {
1516+
t.Fatalf("want %#v but got %#v", wantValue, gotValue)
1517+
}
1518+
1519+
if err := v.DeleteTabpageVar(Tabpage(0), "lua"); err != nil {
1520+
t.Fatal(err)
1521+
}
1522+
1523+
if err := v.TabpageVar(Tabpage(0), "lua", nil); err == nil {
1524+
t.Fatalf("expect Key not found but fonud key")
1525+
}
1526+
})
15031527
})
15041528

15051529
t.Run("Batch", func(t *testing.T) {
@@ -1594,6 +1618,36 @@ func testTabpage(v *Nvim) func(*testing.T) {
15941618
t.Fatalf("expected valid but got %t", valid)
15951619
}
15961620
})
1621+
1622+
t.Run("TabpageVar", func(t *testing.T) {
1623+
b := v.NewBatch()
1624+
1625+
wantValue := []int{1, 2}
1626+
b.SetTabpageVar(Tabpage(0), "lua", wantValue)
1627+
if err := b.Execute(); err != nil {
1628+
t.Fatal(err)
1629+
}
1630+
1631+
var gotValue []int
1632+
b.TabpageVar(Tabpage(0), "lua", &gotValue)
1633+
if err := b.Execute(); err != nil {
1634+
t.Fatal(err)
1635+
}
1636+
1637+
if !reflect.DeepEqual(gotValue, wantValue) {
1638+
t.Fatalf("want %#v but got %#v", wantValue, gotValue)
1639+
}
1640+
1641+
b.DeleteTabpageVar(Tabpage(0), "lua")
1642+
if err := b.Execute(); err != nil {
1643+
t.Fatal(err)
1644+
}
1645+
1646+
b.TabpageVar(Tabpage(0), "lua", nil)
1647+
if err := b.Execute(); err == nil {
1648+
t.Fatalf("expect Key not found but fonud key")
1649+
}
1650+
})
15971651
})
15981652
}
15991653
}

0 commit comments

Comments
 (0)