github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/collection/mutable/set/test/set_go_1_22_test.go (about)

     1  //go:build goexperiment.rangefunc
     2  
     3  package test
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	"github.com/m4gshm/gollections/collection/mutable/set"
    11  	"github.com/m4gshm/gollections/slice"
    12  )
    13  
    14  func Test_Set_Iterate_All(t *testing.T) {
    15  	set := set.Of(1, 1, 2, 4, 3, 1)
    16  	expected := slice.Of(1, 2, 3, 4)
    17  
    18  	out := make(map[int]int, 0)
    19  
    20  	for v := range set.All {
    21  		out[v] = v
    22  	}
    23  
    24  	assert.Equal(t, len(expected), len(out))
    25  	for k := range out {
    26  		assert.True(t, set.Contains(k))
    27  	}
    28  }