2 Commits

Author SHA1 Message Date
ce8c5b516e some tests 2026-02-09 17:39:41 +03:00
8e203ed8d5 some tests 2026-02-09 16:44:16 +03:00
3 changed files with 32 additions and 4 deletions

19
set_test.go Normal file
View File

@@ -0,0 +1,19 @@
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")
}
}

View File

@@ -13,10 +13,7 @@ func (t Tuple[T]) Len() int { return t.s.Len() }
func (t Tuple[T]) Cap() int { return t.s.Cap() }
func (t Tuple[T]) Get(index int) T { return t.s.Get(index) }
func (t Tuple[T]) Equal(t2 Tuple[T]) bool {
if t.Len() != t2.Len() {
return false
}
if t.Cap() != t2.Cap() {
if t.Len() != t2.Len() || t.Cap() != t2.Cap() {
return false
}
for i := range t.s {

12
tuple_test.go Normal file
View File

@@ -0,0 +1,12 @@
package extypes
import "testing"
func TestTuple(t *testing.T) {
t1 := NewTupleFrom([]int{1, 2, 3})
t2 := NewTupleFrom([]int{1, 2, 3})
if !t1.Equal(t2) {
t.Error("t1 and t2 should be equal")
}
}