Skip to content

Commit 1987893

Browse files
committed
Improve test TestAPI/Extmarks/Batch
Do not make assumptions about how nvim_buf_set_extmark() assigns IDs. Validate that SetBufferExtmark returned the correct ID by relying on existing test code code that compares the returned ID with the results from BufferExmarks.
1 parent 77f98f1 commit 1987893

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

nvim/api_test.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4303,17 +4303,13 @@ func testExtmarks(v *Nvim) func(*testing.T) {
43034303
}
43044304

43054305
const (
4306-
wantExtMarkID = 1
4307-
wantLine = 1
4308-
wantCol = 3
4306+
wantLine = 1
4307+
wantCol = 3
43094308
)
43104309
gotExtMarkID, err := v.SetBufferExtmark(Buffer(0), nsID, wantLine, wantCol, make(map[string]interface{}))
43114310
if err != nil {
43124311
t.Fatal(err)
43134312
}
4314-
if gotExtMarkID != wantExtMarkID {
4315-
t.Fatalf("got %d extMarkID but want %d", gotExtMarkID, wantExtMarkID)
4316-
}
43174313

43184314
extmarks, err := v.BufferExtmarks(Buffer(0), nsID, 0, -1, make(map[string]interface{}))
43194315
if err != nil {
@@ -4323,7 +4319,7 @@ func testExtmarks(v *Nvim) func(*testing.T) {
43234319
t.Fatalf("expected extmarks length to 1 but got %d", len(extmarks))
43244320
}
43254321
if extmarks[0].ID != gotExtMarkID {
4326-
t.Fatalf("got %d extMarkID but want %d", extmarks[0].ID, wantExtMarkID)
4322+
t.Fatalf("got %d extMarkID but want %d", extmarks[0].ID, gotExtMarkID)
43274323
}
43284324
if extmarks[0].Row != wantLine {
43294325
t.Fatalf("got %d extmarks Row but want %d", extmarks[0].Row, wantLine)
@@ -4382,18 +4378,14 @@ func testExtmarks(v *Nvim) func(*testing.T) {
43824378
}
43834379

43844380
const (
4385-
wantExtMarkID = 2
4386-
wantLine = 1
4387-
wantCol = 3
4381+
wantLine = 1
4382+
wantCol = 3
43884383
)
43894384
var gotExtMarkID int
43904385
b.SetBufferExtmark(Buffer(0), nsID, wantLine, wantCol, make(map[string]interface{}), &gotExtMarkID)
43914386
if err := b.Execute(); err != nil {
43924387
t.Fatal(err)
43934388
}
4394-
if gotExtMarkID != wantExtMarkID {
4395-
t.Fatalf("got %d extMarkID but want %d", gotExtMarkID, wantExtMarkID)
4396-
}
43974389

43984390
var extmarks []ExtMark
43994391
b.BufferExtmarks(Buffer(0), nsID, 0, -1, make(map[string]interface{}), &extmarks)
@@ -4405,7 +4397,7 @@ func testExtmarks(v *Nvim) func(*testing.T) {
44054397
t.Fatalf("expected extmarks length to 1 but got %d", len(extmarks))
44064398
}
44074399
if extmarks[0].ID != gotExtMarkID {
4408-
t.Fatalf("got %d extMarkID but want %d", extmarks[0].ID, wantExtMarkID)
4400+
t.Fatalf("got %d extMarkID but want %d", extmarks[0].ID, gotExtMarkID)
44094401
}
44104402
if extmarks[0].Row != wantLine {
44114403
t.Fatalf("got %d extmarks Row but want %d", extmarks[0].Row, wantLine)

0 commit comments

Comments
 (0)