Exemple #1
0
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)
	}
}
Exemple #2
0
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)
	}
}