set_test.go 399 B

123456789101112131415161718192021222324252627
  1. package ctn
  2. import "testing"
  3. func TestSetBasic(t *testing.T) {
  4. var s = MakeMutSet[string](StringCompare,
  5. "foo",
  6. "bar",
  7. )
  8. s.Insert("baz")
  9. s.Delete("foo")
  10. if s.Has("foo") {
  11. t.Fatalf("wrong behavior for foo")
  12. }
  13. if !(s.Has("bar")) {
  14. t.Fatalf("wrong behavior for bar")
  15. }
  16. if !(s.Has("baz")) {
  17. t.Fatalf("wrong behavior for baz")
  18. }
  19. s.ForEach(func(item string) {
  20. t.Log(item)
  21. })
  22. }