Пример #1
0
func TestInit(t *testing.T) {
	type int_slice []int
	defer func() {
		if err := recover(); err != nil {
			fmt.Println("catch error:", err)
		} else {
			t.Fatal("not detect error")
		}
	}()
	s1 := int_slice{1, 2, 3}
	s2 := int_slice{1, 2, 3}
	goset.SliceInit([]int_slice{s1, s2})
}
Пример #2
0
func TestContain(t *testing.T) {
	content := []string{"abc", "xyz"}
	s := goset.SliceInit(content)

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