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.
v2ray-core/testing/assert/intsubject.go

42 lines
1.0 KiB

package assert
import (
9 years ago
"github.com/v2ray/v2ray-core/common/serial"
)
func Int(value int) *IntSubject {
9 years ago
return &IntSubject{value: serial.IntLiteral(value)}
}
type IntSubject struct {
Subject
9 years ago
value serial.IntLiteral
}
func (subject *IntSubject) Named(name string) *IntSubject {
subject.Subject.Named(name)
return subject
}
func (subject *IntSubject) DisplayString() string {
9 years ago
return subject.Subject.DisplayString(subject.value.String())
}
func (subject *IntSubject) Equals(expectation int) {
9 years ago
if subject.value.Value() != expectation {
subject.Fail(subject.DisplayString(), "is equal to", serial.IntLiteral(expectation))
}
}
func (subject *IntSubject) GreaterThan(expectation int) {
9 years ago
if subject.value.Value() <= expectation {
subject.Fail(subject.DisplayString(), "is greater than", serial.IntLiteral(expectation))
}
}
func (subject *IntSubject) LessThan(expectation int) {
9 years ago
if subject.value.Value() >= expectation {
subject.Fail(subject.DisplayString(), "is less than", serial.IntLiteral(expectation))
}
}