32 lines
464 B
Go
32 lines
464 B
Go
package extypes
|
|
|
|
import "testing"
|
|
|
|
func TestSet(t *testing.T) {
|
|
s1 := make(Set[int], 0)
|
|
s2 := make(Set[int], 0)
|
|
|
|
s1 = s1.Add(1)
|
|
s1 = s1.Add(2)
|
|
s1 = s1.Add(2)
|
|
|
|
s2 = s2.Add(1)
|
|
s2 = s2.Add(2)
|
|
|
|
if !s1.Equal(s2) {
|
|
t.Error("s1 and s2 not equal")
|
|
}
|
|
}
|
|
|
|
func TestSet_EqualIgnoresCapacity(t *testing.T) {
|
|
s1 := make(Set[int], 2, 2)
|
|
s2 := make(Set[int], 2, 4)
|
|
|
|
s1[0], s1[1] = 1, 2
|
|
s2[0], s2[1] = 1, 2
|
|
|
|
if !s1.Equal(s2) {
|
|
t.Error("s1 and s2 not equal")
|
|
}
|
|
}
|