MCPcopy Create free account
hub / github.com/couchbase/moss / TestSharedPrefixLen

Function TestSharedPrefixLen

iterator_test.go:453–485  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

451}
452
453func TestSharedPrefixLen(t *testing.T) {
454 if sharedPrefixLen(nil, []byte("hi")) != 0 {
455 t.Errorf("not matched")
456 }
457 if sharedPrefixLen([]byte("hi"), nil) != 0 {
458 t.Errorf("not matched")
459 }
460 if sharedPrefixLen(nil, nil) != 0 {
461 t.Errorf("not matched")
462 }
463
464 tests := []struct {
465 a, b string
466 exp int
467 }{
468 {"x", "", 0},
469 {"", "x", 0},
470 {"x", "x", 1},
471 {"x", "xy", 1},
472 {"xy", "x", 1},
473 {"x", "xx", 1},
474 {"xx", "x", 1},
475 {"xx", "xx", 2},
476 {"xx", "xxy", 2},
477 {"xxy", "xx", 2},
478 }
479
480 for _, test := range tests {
481 if sharedPrefixLen([]byte(test.a), []byte(test.b)) != test.exp {
482 t.Errorf("didn't match on test: %#v", test)
483 }
484 }
485}
486
487func TestIteratorSingleDone(t *testing.T) {
488 tmpDir, _ := ioutil.TempDir("", "mossStore")

Callers

nothing calls this directly

Calls 1

sharedPrefixLenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…