2015-12-02 09:27:18 -05:00
|
|
|
package assert
|
2015-09-09 08:51:26 -04:00
|
|
|
|
|
|
|
import (
|
2015-12-03 10:57:23 -05:00
|
|
|
"github.com/v2ray/v2ray-core/common/serial"
|
2015-09-09 08:51:26 -04:00
|
|
|
)
|
|
|
|
|
2015-12-02 09:27:18 -05:00
|
|
|
func Int(value int) *IntSubject {
|
2015-12-03 10:57:23 -05:00
|
|
|
return &IntSubject{value: serial.IntLiteral(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
|
2015-12-03 10:57:23 -05:00
|
|
|
value serial.IntLiteral
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *IntSubject) Named(name string) *IntSubject {
|
|
|
|
subject.Subject.Named(name)
|
|
|
|
return subject
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *IntSubject) DisplayString() string {
|
2015-12-03 10:57:23 -05:00
|
|
|
return subject.Subject.DisplayString(subject.value.String())
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *IntSubject) Equals(expectation int) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() != expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is equal to", serial.IntLiteral(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *IntSubject) GreaterThan(expectation int) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() <= expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is greater than", serial.IntLiteral(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *IntSubject) LessThan(expectation int) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() >= expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is less than", serial.IntLiteral(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|