MCPcopy
hub / github.com/tinode/chat / TestStringSliceDelta

Function TestStringSliceDelta

server/utils_test.go:31–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestStringSliceDelta(t *testing.T) {
32 // Case format:
33 // - inputs: old, new
34 // - expected outputs: added, removed, intersection
35 cases := [][5][]string{
36 {
37 {"abc", "def", "fff"}, {},
38 {}, {"abc", "def", "fff"}, {},
39 },
40 {
41 {}, {}, {}, {}, {},
42 },
43 {
44 {"aa", "xx", "bb", "aa", "bb"}, {"yy", "aa"},
45 {"yy"}, {"aa", "bb", "bb", "xx"}, {"aa"},
46 },
47 {
48 {"bb", "aa", "bb"}, {"yy", "aa", "bb", "zzz", "zzz", "cc"},
49 {"cc", "yy", "zzz", "zzz"}, {"bb"}, {"aa", "bb"},
50 },
51 {
52 {"aa", "aa", "aa"}, {"aa", "aa", "aa"},
53 {}, {}, {"aa", "aa", "aa"},
54 },
55 }
56
57 for _, tc := range cases {
58 added, removed, both := stringSliceDelta(
59 tc[0], tc[1],
60 )
61 expectSlicesEqual(t, "added", tc[2], added)
62 expectSlicesEqual(t, "removed", tc[3], removed)
63 expectSlicesEqual(t, "both", tc[4], both)
64
65 }
66}
67
68func TestParseSearchQuery(t *testing.T) {
69 cases := []struct {

Callers

nothing calls this directly

Calls 2

stringSliceDeltaFunction · 0.85
expectSlicesEqualFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…