Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 101 additions & 329 deletions container/gset/gset_any_set.go

Large diffs are not rendered by default.

402 changes: 99 additions & 303 deletions container/gset/gset_int_set.go

Large diffs are not rendered by default.

421 changes: 100 additions & 321 deletions container/gset/gset_str_set.go

Large diffs are not rendered by default.

531 changes: 531 additions & 0 deletions container/gset/gset_t_set.go

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions container/gset/gset_z_unit_any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ func TestSet_Union(t *testing.T) {
t.Assert(s3.Contains(3), true)
t.Assert(s3.Contains(4), true)
})

// Test with nil element in slice
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewSet()
s2 := gset.NewSet()
s1.Add(1, 2)
s2.Add(3, 4)
s3 := s1.Union(s2, nil)
t.Assert(s3.Contains(1), true)
t.Assert(s3.Contains(2), true)
t.Assert(s3.Contains(3), true)
t.Assert(s3.Contains(4), true)
})
}

func TestSet_Diff(t *testing.T) {
Expand Down Expand Up @@ -236,6 +249,14 @@ func TestSet_Complement(t *testing.T) {
t.Assert(s3.Contains(4), true)
t.Assert(s3.Contains(5), true)
})

// Test with nil full set
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewSet()
s1.Add(1, 2, 3)
s3 := s1.Complement(nil)
t.Assert(s3.Size(), 0)
})
}

func TestNewFrom(t *testing.T) {
Expand Down
21 changes: 21 additions & 0 deletions container/gset/gset_z_unit_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ func TestIntSet_Union(t *testing.T) {
t.Assert(s3.Contains(3), true)
t.Assert(s3.Contains(4), true)
})

// Test with nil element in slice
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewIntSet()
s2 := gset.NewIntSet()
s1.Add(1, 2)
s2.Add(3, 4)
s3 := s1.Union(s2, nil)
t.Assert(s3.Contains(1), true)
t.Assert(s3.Contains(2), true)
t.Assert(s3.Contains(3), true)
t.Assert(s3.Contains(4), true)
})
}

func TestIntSet_Diff(t *testing.T) {
Expand Down Expand Up @@ -216,6 +229,14 @@ func TestIntSet_Complement(t *testing.T) {
t.Assert(s3.Contains(4), true)
t.Assert(s3.Contains(5), true)
})

// Test with nil full set
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewIntSet()
s1.Add(1, 2, 3)
s3 := s1.Complement(nil)
t.Assert(s3.Size(), 0)
})
}

func TestIntSet_Size(t *testing.T) {
Expand Down
21 changes: 21 additions & 0 deletions container/gset/gset_z_unit_str_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ func TestStrSet_Union(t *testing.T) {
t.Assert(s3.Contains("3"), true)
t.Assert(s3.Contains("4"), true)
})

// Test with nil element in slice
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewStrSet()
s2 := gset.NewStrSet()
s1.Add("1", "2")
s2.Add("3", "4")
s3 := s1.Union(s2, nil)
t.Assert(s3.Contains("1"), true)
t.Assert(s3.Contains("2"), true)
t.Assert(s3.Contains("3"), true)
t.Assert(s3.Contains("4"), true)
})
}

func TestStrSet_Diff(t *testing.T) {
Expand Down Expand Up @@ -227,6 +240,14 @@ func TestStrSet_Complement(t *testing.T) {
t.Assert(s3.Contains("4"), true)
t.Assert(s3.Contains("5"), true)
})

// Test with nil full set
gtest.C(t, func(t *gtest.T) {
s1 := gset.NewStrSet()
s1.Add("1", "2", "3")
s3 := s1.Complement(nil)
t.Assert(s3.Size(), 0)
})
}

func TestNewIntSetFrom(t *testing.T) {
Expand Down
Loading
Loading