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