mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
package unit
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
type ByteSubject struct {
|
|
*Subject
|
|
value byte
|
|
}
|
|
|
|
func NewByteSubject(base *Subject, value byte) *ByteSubject {
|
|
subject := new(ByteSubject)
|
|
subject.Subject = base
|
|
subject.value = value
|
|
return subject
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|