-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcomplete_test.go
48 lines (43 loc) · 1.01 KB
/
complete_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package clang_test
import (
"strings"
"testing"
"github.com/sbinet/go-clang"
)
func TestCompleteAt(t *testing.T) {
idx := clang.NewIndex(0, 0)
defer idx.Dispose()
tu := idx.Parse("visitorwrap.c", nil, nil, 0)
if !tu.IsValid() {
t.Fatal("TranslationUnit is not valid")
}
defer tu.Dispose()
const lineno = 10 // ie: call to clang_visitChildren
res := tu.CompleteAt("visitorwrap.c", lineno, 16, nil, 0)
if !res.IsValid() {
t.Fatal("CompleteResults are not valid")
}
defer res.Dispose()
if n := len(res.Results()); n < 10 {
t.Errorf("Expected more results than %d", n)
}
t.Logf("%+v", res)
for _, r := range res.Results() {
t.Logf("%+v", r)
for _, c := range r.CompletionString.Chunks() {
t.Logf("\t%+v", c)
}
}
diags := res.Diagnostics()
defer diags.Dispose()
ok := false
for _, d := range diags {
if strings.Contains(d.Spelling(), "_cgo_export.h") {
ok = true
}
t.Log(d.Severity(), d.Spelling())
}
if !ok {
t.Errorf("Expected to find a diagnostic regarding _cgo_export.h")
}
}