1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
//go:build go1.23
// +build go1.23
package mapset
import (
"testing"
)
func Test_Elements123(t *testing.T) {
a := NewSet[string]()
a.Add("Z")
a.Add("Y")
a.Add("X")
a.Add("W")
b := NewSet[string]()
for elem := range Elements(a) {
b.Add(elem)
}
if !a.Equal(b) {
t.Error("The sets are not equal after iterating (Each) through the first set")
}
var count int
for range Elements(a) {
if count == 2 {
break
}
count++
}
if count != 2 {
t.Error("Iteration should stop on the way")
}
}
|