Пример #1
0
func TestInsertRemove(t *testing.T) {
	s := goset.Set{}

	s.Insert(1)
	s.Insert("hello")

	if !s.Contain(1) {
		t.Fatal("number", 1, "not in set, expect exists")
	} else {
		fmt.Println("1 in set")
	}
	if !s.Contain("hello") {
		t.Fatal("hello not in set, expect exists")
	} else {
		fmt.Println("hello in set")
	}

	s.Remove(1)
	s.Remove("hello")
	if s.Contain(1) {
		t.Fatal("number", 1, "exists, expect remove")
	}
	if s.Contain("hello") {
		t.Fatal("hello exists, expect remove")
	}
	if s.Len() != 0 {
		t.Fatal("length of s should be zero!")
	}
}