1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/testing/assert/uint32.go

51 lines
1022 B
Go
Raw Normal View History

2016-06-27 16:22:01 -04:00
package assert
import (
2016-08-20 14:55:45 -04:00
"v2ray.com/core/common/serial"
2016-06-27 16:22:01 -04:00
)
2016-11-27 15:39:09 -05:00
func (v *Assert) Uint32(value uint32) *Uint32Subject {
2016-06-27 16:22:01 -04:00
return &Uint32Subject{
Subject: Subject{
2016-11-27 15:39:09 -05:00
a: v,
2016-06-27 16:22:01 -04:00
disp: serial.Uint32ToString(value),
},
value: value,
}
}
type Uint32Subject struct {
Subject
value uint32
}
func (subject *Uint32Subject) Equals(expectation uint32) {
if subject.value != expectation {
subject.Fail("is equal to", serial.Uint32ToString(expectation))
}
}
func (subject *Uint32Subject) GreaterThan(expectation uint32) {
if subject.value <= expectation {
subject.Fail("is greater than", serial.Uint32ToString(expectation))
}
}
func (subject *Uint32Subject) LessThan(expectation uint32) {
if subject.value >= expectation {
subject.Fail("is less than", serial.Uint32ToString(expectation))
}
}
func (subject *Uint32Subject) IsPositive() {
if subject.value <= 0 {
subject.Fail("is", "positive")
}
}
func (subject *Uint32Subject) IsNegative() {
if subject.value >= 0 {
subject.Fail("is not", "negative")
}
}