2015-12-02 09:27:18 -05:00
|
|
|
package assert
|
|
|
|
|
|
|
|
import (
|
2015-12-02 10:19:39 -05:00
|
|
|
"github.com/v2ray/v2ray-core/common/serial"
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Subject struct {
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSubject() *Subject {
|
|
|
|
return &Subject{
|
|
|
|
name: "",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 10:19:39 -05:00
|
|
|
func (subject *Subject) Fail(displayString string, verb string, other serial.String) {
|
|
|
|
subject.FailWithMessage("Not true that " + displayString + " " + verb + " <" + other.String() + ">.")
|
|
|
|
}
|
|
|
|
|
2015-12-02 09:27:18 -05:00
|
|
|
func (subject *Subject) FailWithMessage(message string) {
|
|
|
|
v2testing.Fail(message)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Subject) Named(name string) {
|
|
|
|
subject.name = name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (subject *Subject) DisplayString(value string) string {
|
|
|
|
if len(value) == 0 {
|
|
|
|
value = "unknown"
|
|
|
|
}
|
|
|
|
if len(subject.name) == 0 {
|
|
|
|
return "<" + value + ">"
|
|
|
|
}
|
|
|
|
return subject.name + "(<" + value + ">)"
|
|
|
|
}
|