1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
package assert
import "testing"
type Assertion struct {
t testing.TB
}
func New(t testing.TB) *Assertion {
return &Assertion{t: t}
}
func (a *Assertion) TB() testing.TB {
return a.t
}
func (a *Assertion) True(expr bool, msg ...interface{}) *Assertion {
True(a.t, expr, msg...)
return a
}
func (a *Assertion) False(expr bool, msg ...interface{}) *Assertion {
False(a.t, expr, msg...)
return a
}
func (a *Assertion) Nil(expr interface{}, msg ...interface{}) *Assertion {
Nil(a.t, expr, msg...)
return a
}
func (a *Assertion) NotNil(expr interface{}, msg ...interface{}) *Assertion {
NotNil(a.t, expr, msg...)
return a
}
func (a *Assertion) Equal(v1, v2 interface{}, msg ...interface{}) *Assertion {
Equal(a.t, v1, v2, msg...)
return a
}
func (a *Assertion) NotEqual(v1, v2 interface{}, msg ...interface{}) *Assertion {
NotEqual(a.t, v1, v2, msg...)
return a
}
func (a *Assertion) Empty(expr interface{}, msg ...interface{}) *Assertion {
Empty(a.t, expr, msg...)
return a
}
func (a *Assertion) NotEmpty(expr interface{}, msg ...interface{}) *Assertion {
NotEmpty(a.t, expr, msg...)
return a
}
func (a *Assertion) Error(expr interface{}, msg ...interface{}) *Assertion {
Error(a.t, expr, msg...)
return a
}
func (a *Assertion) ErrorString(expr interface{}, str string, msg ...interface{}) *Assertion {
ErrorString(a.t, expr, str, msg...)
return a
}
func (a *Assertion) ErrorType(expr interface{}, typ error, msg ...interface{}) *Assertion {
ErrorType(a.t, expr, typ, msg...)
return a
}
func (a *Assertion) NotError(expr interface{}, msg ...interface{}) *Assertion {
NotError(a.t, expr, msg...)
return a
}
func (a *Assertion) FileExists(path string, msg ...interface{}) *Assertion {
FileExists(a.t, path, msg...)
return a
}
func (a *Assertion) FileNotExists(path string, msg ...interface{}) *Assertion {
FileNotExists(a.t, path, msg...)
return a
}
func (a *Assertion) Panic(fn func(), msg ...interface{}) *Assertion {
Panic(a.t, fn, msg...)
return a
}
func (a *Assertion) PanicString(fn func(), str string, msg ...interface{}) *Assertion {
PanicString(a.t, fn, str, msg...)
return a
}
func (a *Assertion) PanicType(fn func(), typ interface{}, msg ...interface{}) *Assertion {
PanicType(a.t, fn, typ, msg...)
return a
}
func (a *Assertion) NotPanic(fn func(), msg ...interface{}) *Assertion {
NotPanic(a.t, fn, msg...)
return a
}
func (a *Assertion) Contains(container, item interface{}, msg ...interface{}) *Assertion {
Contains(a.t, container, item, msg...)
return a
}
func (a *Assertion) NotContains(container, item interface{}, msg ...interface{}) *Assertion {
NotContains(a.t, container, item, msg...)
return a
}
|