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.
49 lines
1.1 KiB
49 lines
1.1 KiB
package unit
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
type Uint16Subject struct {
|
|
*Subject
|
|
value uint16
|
|
}
|
|
|
|
func NewUint16Subject(base *Subject, value uint16) *Uint16Subject {
|
|
subject := new(Uint16Subject)
|
|
subject.Subject = base
|
|
subject.value = value
|
|
return subject
|
|
}
|
|
|
|
func (subject *Uint16Subject) Named(name string) *Uint16Subject {
|
|
subject.Subject.Named(name)
|
|
return subject
|
|
}
|
|
|
|
func (subject *Uint16Subject) Fail(verb string, other uint16) {
|
|
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(int(other)) + ">.")
|
|
}
|
|
|
|
func (subject *Uint16Subject) DisplayString() string {
|
|
return subject.Subject.DisplayString(strconv.Itoa(int(subject.value)))
|
|
}
|
|
|
|
func (subject *Uint16Subject) Equals(expectation uint16) {
|
|
if subject.value != expectation {
|
|
subject.Fail("is equal to", expectation)
|
|
}
|
|
}
|
|
|
|
func (subject *Uint16Subject) GreaterThan(expectation uint16) {
|
|
if subject.value <= expectation {
|
|
subject.Fail("is greater than", expectation)
|
|
}
|
|
}
|
|
|
|
func (subject *Uint16Subject) LessThan(expectation uint16) {
|
|
if subject.value >= expectation {
|
|
subject.Fail("is less than", expectation)
|
|
}
|
|
}
|