1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-19 10:56:06 -05:00
v2fly/testing/unit/uint16subject.go

55 lines
1.2 KiB
Go
Raw Normal View History

package unit
import (
"strconv"
)
type Uint16Subject struct {
*Subject
value uint16
}
func NewUint16Subject(base *Subject, value uint16) *Uint16Subject {
2015-09-20 07:08:05 -04:00
return &Uint16Subject{
Subject: base,
value: value,
}
}
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)
}
}
2015-09-20 05:45:40 -04:00
func (subject *Uint16Subject) Positive() {
if subject.value <= 0 {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is positive.")
}
}