Skip to content

Commit

Permalink
broke the test in pieces
Browse files Browse the repository at this point in the history
Signed-off-by: Divya Pamecha <[email protected]>
  • Loading branch information
Its-Maniaco committed Jan 25, 2024
1 parent 1d298d8 commit 952c5fb
Showing 1 changed file with 42 additions and 18 deletions.
60 changes: 42 additions & 18 deletions go/sets/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,57 @@ import (
"github.com/stretchr/testify/assert"
)

func TestSet(t *testing.T) {
func TestInsert(t *testing.T) {
testSet := New[int](1, 2, 3)

assert.Equal(t, testSet.Len(), 3)

testSet.Insert(4, 5, 6)
compareSet := New[int](1, 2, 3, 4, 5, 6)
assert.Equal(t, testSet, compareSet)
}

assert.True(t, testSet.Equal(compareSet))
compareSet.Insert(-1, -2)
assert.False(t, testSet.Equal(compareSet))

//tests for Difference func
diffSet := New[int](-1, -2)
assert.Equal(t, diffSet, compareSet.Difference(testSet))
func TestDelete(t *testing.T) {
testSet := New[int](1, 2, 3, 4, 5, 6)
testSet.Delete(1, 5)
compareSet := New[int](2, 3, 4, 6)
assert.Equal(t, testSet, compareSet)
testSet.Delete(2, 3, 4, 6)
assert.Empty(t, testSet)
}

//tests for Has func
func TestHas(t *testing.T) {
testSet := New[int](1, 2, 3)
assert.True(t, testSet.Has(3))
assert.False(t, testSet.Has(-1))
}

func TestHasAny(t *testing.T) {
testSet := New[int](1, 2, 3)
assert.True(t, testSet.HasAny(1, 10, 11))
assert.False(t, testSet.HasAny(-1, 10, 11))
}

//tests for HasAny func
assert.True(t, testSet.HasAny(1, 10, 11, 12))
assert.False(t, testSet.HasAny(-1, 10, 11, 12))
func TestDifference(t *testing.T) {
testSet := New[int](1, 2, 3)
compareSet := New[int](-1, -2, 1, 2, 3)
diffSet := New[int](-1, -2)
assert.Equal(t, diffSet, compareSet.Difference(testSet))
}

//tests for Delete func
testSet.Delete(1, 2, 3, 4, 5, 6)
assert.Empty(t, testSet)
func TestIntersection(t *testing.T) {
setA := New[int](1, 2, 3)
setB := New[int](1, 2, 8, 9, 10)
expectedSet := New[int](1, 2)
assert.Equal(t, expectedSet, setA.Intersection(setB))
}

func TestEqual(t *testing.T) {
testSet := New[int](1, 2, 3, 4, 5, 6)
compareSet := New[int](1, 2, 3, 4, 5, 6)
assert.True(t, testSet.Equal(compareSet))
compareSet.Insert(-1, -2)
assert.False(t, testSet.Equal(compareSet))
}

func TestLen(t *testing.T) {
testSet := New[int](1, 2, 3)
assert.Equal(t, testSet.Len(), 3)
}

0 comments on commit 952c5fb

Please sign in to comment.