Skip to content

Commit

Permalink
add test for distinct elements
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed Jun 30, 2024
1 parent 6ff9ed0 commit 28d0eb8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hashset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import (
"github.com/stretchr/testify/assert"
)

func TestElementsAreDistinct(t *testing.T) {
a := New(5, 1, 2, 3, 4, 5)
a.Add(2)
a.Add(3)
a.Add(3)
assert.True(t, a.Len() == 5)

for i := 0; i < a.Len(); i++ {
random, _ := a.Pop()
assert.True(t, !a.Contains(random))
}
}

func TestInstantiationWithElements(t *testing.T) {
set := New(5, 1, 2, 3, 4, 5)
assert.Equal(t, set.Len(), 5)
Expand Down

0 comments on commit 28d0eb8

Please sign in to comment.