Example #1
0
func StringContains(actual interface{}, criteria interface{}) (match bool,
	pos gospec.Message, neg gospec.Message, err error) {
	toTest := actual.(string)
	critTest := criteria.(string)
	match = strings.Contains(toTest, critTest)
	pos = gospec.Messagef(toTest, "contains "+critTest)
	neg = gospec.Messagef(toTest, "does not contain "+critTest)
	return
}
Example #2
0
func StringStartsWith(actual interface{}, criteria interface{}) (match bool,
	pos gospec.Message, neg gospec.Message, err error) {
	actStr := actual.(string)
	critStr := criteria.(string)
	match = actStr[:len(critStr)] == critStr
	pos = gospec.Messagef(actStr, "starts with %s", critStr)
	neg = gospec.Messagef(actStr, "does not start with %s", critStr)
	return
}