mirror of https://github.com/v2ray/v2ray-core
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.
51 lines
975 B
51 lines
975 B
package assert
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func (v *Assert) String(value string) *StringSubject {
|
|
return &StringSubject{
|
|
Subject: Subject{
|
|
a: v,
|
|
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)
|
|
}
|
|
}
|
|
|
|
func (subject *StringSubject) IsEmpty() {
|
|
if len(subject.value) > 0 {
|
|
subject.FailWithMessage("is not empty.")
|
|
}
|
|
}
|