github.com/searKing/golang/go@v1.2.117/exp/maps/set_test.go (about)

     1  // Copyright 2022 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package maps_test
     6  
     7  import (
     8  	"testing"
     9  
    10  	maps_ "github.com/searKing/golang/go/exp/maps"
    11  	"golang.org/x/exp/maps"
    12  )
    13  
    14  var m1 = map[int]struct{}{1: {}, 2: {}, 4: {}, 8: {}}
    15  
    16  func TestSet(t *testing.T) {
    17  	mc := maps_.Set(maps.Keys(m1)...)
    18  	if !maps.Equal(mc, m1) {
    19  		t.Errorf("Set(%v) = %v, want %v", m1, mc, m1)
    20  	}
    21  	mc[16] = struct{}{}
    22  	if maps.Equal(mc, m1) {
    23  		t.Errorf("Equal(%v, %v) = true, want false", mc, m1)
    24  	}
    25  }