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.
32 lines
580 B
32 lines
580 B
package unit
|
|
|
|
type Subject struct {
|
|
assert *Assertion
|
|
name string
|
|
}
|
|
|
|
func NewSubject(assert *Assertion) *Subject {
|
|
subject := new(Subject)
|
|
subject.assert = assert
|
|
subject.name = ""
|
|
return subject
|
|
}
|
|
|
|
func (subject *Subject) FailWithMessage(message string) {
|
|
subject.assert.t.Error(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 + ">)"
|
|
}
|