MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestSet

Function TestSet

util/set/set_test.go:12–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestSet(t *testing.T) {
13 s := Set[int]{}
14 s.Add(1)
15 s.Add(2)
16 if !s.Contains(1) {
17 t.Error("missing 1")
18 }
19 if !s.Contains(2) {
20 t.Error("missing 2")
21 }
22 if s.Contains(3) {
23 t.Error("shouldn't have 3")
24 }
25 if s.Len() != 2 {
26 t.Errorf("wrong len %d; want 2", s.Len())
27 }
28
29 more := []int{3, 4}
30 s.AddSlice(more)
31 if !s.Contains(3) {
32 t.Error("missing 3")
33 }
34 if !s.Contains(4) {
35 t.Error("missing 4")
36 }
37 if s.Contains(5) {
38 t.Error("shouldn't have 5")
39 }
40 if s.Len() != 4 {
41 t.Errorf("wrong len %d; want 4", s.Len())
42 }
43
44 es := s.Slice()
45 if len(es) != 4 {
46 t.Errorf("slice has wrong len %d; want 4", len(es))
47 }
48 for _, e := range []int{1, 2, 3, 4} {
49 if !slices.Contains(es, e) {
50 t.Errorf("slice missing %d (%#v)", e, es)
51 }
52 }
53}
54
55func TestSetOf(t *testing.T) {
56 s := Of(1, 2, 3, 4, 4, 1)

Callers

nothing calls this directly

Calls 7

AddMethod · 0.65
ErrorMethod · 0.65
LenMethod · 0.65
ErrorfMethod · 0.65
ContainsMethod · 0.45
AddSliceMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…