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 Uint16(value uint16) *Uint16Subject {
|
2015-12-03 10:57:23 -05:00
|
|
|
return &Uint16Subject{value: serial.Uint16Literal(value)}
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 09:27:18 -05:00
|
|
|
type Uint16Subject struct {
|
|
|
|
Subject
|
2015-12-03 10:57:23 -05:00
|
|
|
value serial.Uint16Literal
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Uint16Subject) Named(name string) *Uint16Subject {
|
|
|
|
subject.Subject.Named(name)
|
|
|
|
return subject
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Uint16Subject) 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 *Uint16Subject) Equals(expectation uint16) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() != expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is equal to", serial.Uint16Literal(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Uint16Subject) GreaterThan(expectation uint16) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() <= expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is greater than", serial.Uint16Literal(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Uint16Subject) LessThan(expectation uint16) {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() >= expectation {
|
|
|
|
subject.Fail(subject.DisplayString(), "is less than", serial.Uint16Literal(expectation))
|
2015-09-09 08:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
2015-09-20 05:45:40 -04:00
|
|
|
|
|
|
|
func (subject *Uint16Subject) Positive() {
|
2015-12-03 10:57:23 -05:00
|
|
|
if subject.value.Value() <= 0 {
|
2015-09-20 05:45:40 -04:00
|
|
|
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is positive.")
|
|
|
|
}
|
|
|
|
}
|