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