mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-29 15:33:44 +00:00
massive refactoring against unit test lib
This commit is contained in:
1 parent
cee85bdf26
commit
0a2e4343bc
44 files changed
+327
-317
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Uint16(value uint16) *Uint16Subject {
|
||||
return &Uint16Subject{value: value}
|
||||
}
|
||||
|
||||
type Uint16Subject struct {
|
||||
Subject
|
||||
value uint16
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *Uint16Subject) Positive() {
|
||||
if subject.value <= 0 {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is positive.")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user