Слияние кода завершено, страница обновится автоматически
package tug
import (
"strings"
)
func toString(o interface{}) string {
return o.(string)
}
type startWith struct {
BaseMatcher
}
func (this *startWith) Match(actual interface{}) bool {
excepted := toString(this.Expected)
if str, ok := actual.(string); ok {
return strings.HasPrefix(str, excepted)
}
return false
}
func StartWith(expected string) Matcher {
matcher := &startWith{}
matcher.Expected=expected
matcher.Reason="%v %s start with %v"
return matcher
}
type endWith struct {
BaseMatcher
}
func (this *endWith) Match(actual interface{}) bool {
excepted := toString(this.Expected)
if str, ok := actual.(string); ok {
return strings.HasSuffix(str, excepted)
}
return false
}
func EndWith(expected string) Matcher {
matcher := &endWith{}
matcher.Expected=expected
matcher.Reason="%v %s end with %v"
return matcher
}
type containString struct {
BaseMatcher
}
func (this *containString) Match(actual interface{}) bool {
excepted := toString(this.Expected)
if str, ok := actual.(string); ok {
return strings.Contains(str, excepted)
}
return false
}
func ContainString(expected string) Matcher {
matcher := &containString{}
matcher.Expected=expected
matcher.Reason="%v %s contain %v"
return matcher
}
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )