subject.go 545 B

123456789101112131415161718192021222324252627282930313233
  1. package assert
  2. import (
  3. v2testing "github.com/v2ray/v2ray-core/testing"
  4. )
  5. type Subject struct {
  6. name string
  7. }
  8. func NewSubject() *Subject {
  9. return &Subject{
  10. name: "",
  11. }
  12. }
  13. func (subject *Subject) FailWithMessage(message string) {
  14. v2testing.Fail(message)
  15. }
  16. func (subject *Subject) Named(name string) {
  17. subject.name = name
  18. }
  19. func (subject *Subject) DisplayString(value string) string {
  20. if len(value) == 0 {
  21. value = "unknown"
  22. }
  23. if len(subject.name) == 0 {
  24. return "<" + value + ">"
  25. }
  26. return subject.name + "(<" + value + ">)"
  27. }