1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-09 03:37:37 -05:00
v2fly/testing/assert/uint16subject.go

48 lines
1.2 KiB
Go
Raw Normal View History

package assert
import (
2015-12-03 10:57:23 -05:00
"github.com/v2ray/v2ray-core/common/serial"
)
func Uint16(value uint16) *Uint16Subject {
2015-12-03 10:57:23 -05:00
return &Uint16Subject{value: serial.Uint16Literal(value)}
}
type Uint16Subject struct {
Subject
2015-12-03 10:57:23 -05:00
value serial.Uint16Literal
}
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())
}
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))
}
}
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))
}
}
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-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.")
}
}