1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-06 10:20:44 -05:00
v2fly/testing/assert/string.go

45 lines
861 B
Go
Raw Normal View History

2016-05-24 15:55:46 -04:00
package assert
import (
"strings"
)
func (this *Assert) String(value string) *StringSubject {
return &StringSubject{
Subject: Subject{
a: this,
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)
}
}