You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/testing/assert/string.go

45 lines
855 B

9 years ago
package assert
import (
"strings"
)
8 years ago
func (v *Assert) String(value string) *StringSubject {
9 years ago
return &StringSubject{
Subject: Subject{
8 years ago
a: v,
9 years ago
disp: value,
},
value: value,
}
}
type StringSubject struct {
Subject
value string
}
func (subject *StringSubject) Equals(expectation string) {
if subject.value != expectation {
subject.Fail("is equal to", expectation)
}
}
func (subject *StringSubject) NotEquals(expectation string) {
if subject.value == expectation {
subject.Fail("is not equal to ", expectation)
}
}
func (subject *StringSubject) Contains(substring string) {
if !strings.Contains(subject.value, substring) {
subject.Fail("contains", substring)
}
}
func (subject *StringSubject) NotContains(substring string) {
if strings.Contains(subject.value, substring) {
subject.Fail("doesn't contain", substring)
}
}