1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-29 18:45:23 +00:00
v2fly/testing/unit/bytesubject.go
2015-09-20 13:08:05 +02:00

49 lines
1.0 KiB
Go

package unit
import (
"strconv"
)
type ByteSubject struct {
*Subject
value byte
}
func NewByteSubject(base *Subject, value byte) *ByteSubject {
return &ByteSubject{
Subject: base,
value: value,
}
}
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)
}
}