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.
46 lines
990 B
46 lines
990 B
9 years ago
|
package assert
|
||
9 years ago
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
9 years ago
|
func Int(value int) *IntSubject {
|
||
|
return &IntSubject{value: value}
|
||
|
}
|
||
|
|
||
9 years ago
|
type IntSubject struct {
|
||
|
*Subject
|
||
|
value int
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) Named(name string) *IntSubject {
|
||
|
subject.Subject.Named(name)
|
||
|
return subject
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) Fail(verb string, other int) {
|
||
|
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(other) + ">.")
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) DisplayString() string {
|
||
|
return subject.Subject.DisplayString(strconv.Itoa(subject.value))
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) Equals(expectation int) {
|
||
|
if subject.value != expectation {
|
||
|
subject.Fail("is equal to", expectation)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) GreaterThan(expectation int) {
|
||
|
if subject.value <= expectation {
|
||
|
subject.Fail("is greater than", expectation)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (subject *IntSubject) LessThan(expectation int) {
|
||
|
if subject.value >= expectation {
|
||
|
subject.Fail("is less than", expectation)
|
||
|
}
|
||
|
}
|