mirror of https://github.com/tailscale/tailscale/
util/set: add a basic map-based Set type
We have two other types of Sets here. Add the basic obvious one too. Needed for a change elsewhere. Updates #cleanup Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/8123/head
parent
84c99fe0d9
commit
b69059334b
@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package set
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
s := Set[int]{}
|
||||
s.Add(1)
|
||||
s.Add(2)
|
||||
if !s.Contains(1) {
|
||||
t.Error("missing 1")
|
||||
}
|
||||
if !s.Contains(2) {
|
||||
t.Error("missing 2")
|
||||
}
|
||||
if s.Contains(3) {
|
||||
t.Error("shouldn't have 3")
|
||||
}
|
||||
if s.Len() != 2 {
|
||||
t.Errorf("wrong len %d; want 2", s.Len())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue