v2ray-core/testing/assert/intsubject.go

39 lines
752 B
Go
Raw Normal View History

package assert
import (
2016-08-20 20:55:45 +02:00
"v2ray.com/core/common/serial"
)
2016-11-27 21:39:09 +01:00
func (v *Assert) Int(value int) *IntSubject {
2016-05-24 21:55:46 +02:00
return &IntSubject{
Subject: Subject{
2016-11-27 21:39:09 +01:00
a: v,
2016-05-24 21:55:46 +02:00
disp: serial.IntToString(value),
},
value: value,
}
}
type IntSubject struct {
2015-12-02 20:44:01 +00:00
Subject
2016-05-24 21:55:46 +02:00
value int
}
func (subject *IntSubject) Equals(expectation int) {
2016-05-24 21:55:46 +02:00
if subject.value != expectation {
subject.Fail("is equal to", serial.IntToString(expectation))
}
}
func (subject *IntSubject) GreaterThan(expectation int) {
2016-05-24 21:55:46 +02:00
if subject.value <= expectation {
subject.Fail("is greater than", serial.IntToString(expectation))
}
}
func (subject *IntSubject) LessThan(expectation int) {
2016-05-24 21:55:46 +02:00
if subject.value >= expectation {
subject.Fail("is less than", serial.IntToString(expectation))
}
}