mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-10-16 14:04:03 -04:00
massive refactoring against unit test lib
This commit is contained in:
45
testing/assert/bytesubject.go
Normal file
45
testing/assert/bytesubject.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package assert
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Byte(value byte) *ByteSubject {
|
||||
return &ByteSubject{value: value}
|
||||
}
|
||||
|
||||
type ByteSubject struct {
|
||||
Subject
|
||||
value byte
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) Named(name string) *ByteSubject {
|
||||
subject.Subject.Named(name)
|
||||
return subject
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) Fail(verb string, other byte) {
|
||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(int(other)) + ">.")
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) DisplayString() string {
|
||||
return subject.Subject.DisplayString(strconv.Itoa(int(subject.value)))
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) Equals(expectation byte) {
|
||||
if subject.value != expectation {
|
||||
subject.Fail("is equal to", expectation)
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) GreaterThan(expectation byte) {
|
||||
if subject.value <= expectation {
|
||||
subject.Fail("is greater than", expectation)
|
||||
}
|
||||
}
|
||||
|
||||
func (subject *ByteSubject) LessThan(expectation byte) {
|
||||
if subject.value >= expectation {
|
||||
subject.Fail("is less than", expectation)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user