mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-03 16:24:04 +00:00
Unit test library to simplify test writing
This commit is contained in:
1 parent
526c3d3a9b
commit
08a96e5fe1
7 files changed
+266
-33
No files matched your search
@@ -0,0 +1,31 @@
|
||||
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 + ">)"
|
||||
}
|
||||
Reference in new issue
Block a user