File: set123_test.go

package info (click to toggle)
golang-github-deckarep-golang-set 2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 320 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 516 bytes parent folder | download
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")
	}
}