MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / TestAdd

Function TestAdd

utilities/trie_test.go:239–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func TestAdd(t *testing.T) {
240 for _, spec := range []struct {
241 tokens [][]string
242 want utilities.DoubleArray
243 }{
244 {
245 want: utilities.DoubleArray{
246 Encoding: make(map[string]int),
247 },
248 },
249 {
250 tokens: [][]string{{"foo"}},
251 want: utilities.DoubleArray{
252 Encoding: map[string]int{"foo": 0},
253 Base: []int{1, 1, 0},
254 Check: []int{0, 1, 2},
255 // 0: ^
256 // 1: ^foo
257 // 2: ^foo$
258 },
259 },
260 {
261 tokens: [][]string{{"foo"}, {"bar"}},
262 want: utilities.DoubleArray{
263 Encoding: map[string]int{
264 "foo": 0,
265 "bar": 1,
266 },
267 Base: []int{1, 1, 2, 0, 0},
268 Check: []int{0, 1, 1, 2, 3},
269 // 0: ^
270 // 1: ^foo
271 // 2: ^bar
272 // 3: ^foo$
273 // 4: ^bar$
274 },
275 },
276 {
277 tokens: [][]string{{"foo", "bar"}, {"foo", "baz"}},
278 want: utilities.DoubleArray{
279 Encoding: map[string]int{
280 "foo": 0,
281 "bar": 1,
282 "baz": 2,
283 },
284 Base: []int{1, 1, 1, 2, 0, 0},
285 Check: []int{0, 1, 2, 2, 3, 4},
286 // 0: ^
287 // 1: ^foo
288 // 2: ^foo.bar
289 // 3: ^foo.baz
290 // 4: ^foo.bar$
291 // 5: ^foo.baz$
292 },
293 },
294 {
295 tokens: [][]string{{"foo", "bar"}, {"foo", "baz"}, {"qux"}},
296 want: utilities.DoubleArray{

Callers

nothing calls this directly

Calls 2

NewDoubleArrayFunction · 0.92
compareArrayFunction · 0.85

Tested by

no test coverage detected