예제 #1
0
파일: stdlib_test.go 프로젝트: juju/utils
func (s stdlibSuite) TestMatchBadPattern(c *gc.C) {
	tests := map[string]string{
		"ab[":    "abc",
		"ab[-c]": "abc",
		"ab[]":   "abc",
	}
	for pattern, name := range tests {
		c.Logf("- checking pattern %q against %q -", pattern, name)
		_, err := filepath.Match(gofilepath.Separator, pattern, name)

		_, goerr := gofilepath.Match(pattern, name)
		c.Check(err, gc.Equals, goerr)
		c.Check(err, gc.Equals, gofilepath.ErrBadPattern)
	}
}
예제 #2
0
파일: stdlib_test.go 프로젝트: juju/utils
func (s stdlibSuite) TestMatchFalse(c *gc.C) {
	tests := map[string]string{
		"abc": "xyz",
		"":    "abc",
		"a*c": "a",
		"?":   "",
		"a?c": "ac",
	}
	for pattern, name := range tests {
		c.Logf("- checking pattern %q against %q -", pattern, name)
		matched, err := filepath.Match(gofilepath.Separator, pattern, name)
		c.Assert(err, jc.ErrorIsNil)

		gomatched, err := gofilepath.Match(pattern, name)
		c.Assert(err, jc.ErrorIsNil)
		c.Check(matched, gc.Equals, gomatched)
		c.Check(matched, jc.IsFalse)
	}
}