Пример #1
0
func TestFilter(t *testing.T) {
	a := []string{"foo", "foo", "bar"}
	ex := []string{"foo", "foo"}
	i := filterutils.Filter(a, func(i int) bool { return a[i] == "foo" })
	if !reflect.DeepEqual(i, ex) {
		// XXX Arg... string formatting
		t.Errorf("Filter test has failed. Expected %s, Actual %s", ex, i)
	}
}
Пример #2
0
func findFiles(imagePath, fileType string) []string {
	dir, err := filetree.GetDir(imagePath)
	if err != nil {
		panic(err)
	}
	files, err := dir.GetFilePaths()
	if err != nil {
		panic(err)
	}
	return filterutils.Filter(
		files,
		func(i int) bool { return strings.HasSuffix(files[i], fileType) },
	)
}