MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestNew

Function TestNew

structure/set/set_test.go:7–20  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestNew(t *testing.T) {
8 set := New(1, 2, 3)
9 if set.Len() != 3 {
10 t.Errorf("expecting 3 elements in the set but got %v: %v", set.Len(), set.GetItems())
11 }
12 for _, n := range []int{1, 2, 3} {
13 if !set.In(n) {
14 t.Errorf("expecting %d to be present in the set but was not; set is %v", n, set.GetItems())
15 }
16 }
17 if set.In(5) {
18 t.Errorf("expecting 5 not to be present in the set but it was; set is %v", set.GetItems())
19 }
20}
21
22func TestAdd(t *testing.T) {
23 td := []struct {

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
LenMethod · 0.65
GetItemsMethod · 0.65
InMethod · 0.65

Tested by

no test coverage detected