MCPcopy Create free account
hub / github.com/posener/complete / TestPredict

Function TestPredict

predict/predict_test.go:10–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestPredict(t *testing.T) {
11 tests := []struct {
12 name string
13 p complete.Predictor
14 prefix string
15 want []string
16 }{
17 {
18 name: "set",
19 p: Set{"a", "b", "c"},
20 want: []string{"a", "b", "c"},
21 },
22 {
23 name: "set/empty",
24 p: Set{},
25 want: []string{},
26 },
27 {
28 name: "or: word with nil",
29 p: Or(Set{"a"}, nil),
30 want: []string{"a"},
31 },
32 {
33 name: "or: nil with word",
34 p: Or(nil, Set{"a"}),
35 want: []string{"a"},
36 },
37 {
38 name: "or: word with word with word",
39 p: Or(Set{"a"}, Set{"b"}, Set{"c"}),
40 want: []string{"a", "b", "c"},
41 },
42 {
43 name: "something",
44 p: Something,
45 want: []string{""},
46 },
47 {
48 name: "nothing",
49 p: Nothing,
50 prefix: "a",
51 want: []string{},
52 },
53 }
54
55 for _, tt := range tests {
56 t.Run(tt.name, func(t *testing.T) {
57 got := tt.p.Predict(tt.prefix)
58 assert.ElementsMatch(t, tt.want, got, "Got: %+v", got)
59 })
60 }
61}

Callers

nothing calls this directly

Calls 2

OrFunction · 0.85
PredictMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…