v2ray-core/testing/assert/uint16.go

51 lines
1022 B
Go
Raw Normal View History

2016-05-24 19:55:46 +00:00
package assert
import (
2016-08-20 18:55:45 +00:00
"v2ray.com/core/common/serial"
2016-05-24 19:55:46 +00:00
)
2016-11-27 20:39:09 +00:00
func (v *Assert) Uint16(value uint16) *Uint16Subject {
2016-05-24 19:55:46 +00:00
return &Uint16Subject{
Subject: Subject{
2016-11-27 20:39:09 +00:00
a: v,
2016-05-24 19:55:46 +00:00
disp: serial.Uint16ToString(value),
},
value: value,
}
}
type Uint16Subject struct {
Subject
value uint16
}
func (subject *Uint16Subject) Equals(expectation uint16) {
if subject.value != expectation {
subject.Fail("is equal to", serial.Uint16ToString(expectation))
}
}
func (subject *Uint16Subject) GreaterThan(expectation uint16) {
if subject.value <= expectation {
subject.Fail("is greater than", serial.Uint16ToString(expectation))
}
}
func (subject *Uint16Subject) LessThan(expectation uint16) {
if subject.value >= expectation {
subject.Fail("is less than", serial.Uint16ToString(expectation))
}
}
func (subject *Uint16Subject) IsPositive() {
if subject.value <= 0 {
subject.Fail("is", "positive")
}
}
func (subject *Uint16Subject) IsNegative() {
if subject.value >= 0 {
subject.Fail("is not", "negative")
}
}