func TestPanic(t *testing.T) { defer func() { if err := recover(); err != nil { fmt.Println(err) } else { fmt.Println("no paic!") t.Fatal("expect panic!") } }() s := goset.Set{} //s.Insert(3) s.Insert([]int{1, 2, 3}) }
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!") } }