This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
assert.go
65 lines (51 loc) · 1.78 KB
/
assert.go
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
package tt
import (
"testing"
)
// AssertEqual validates that val1 is equal to val2 and throws an error with line number
func AssertEqual(t *testing.T, expected, actual interface{}) {
equalSkip(t, 2, expected, actual)
}
// AssertNotEqual validates that val1 is not equal val2 and throws an error with line number
func AssertNotEqual(t *testing.T, unexpected, actual interface{}) {
notEqualSkip(t, 2, unexpected, actual)
}
// AssertMatchRegex validates that value matches the regex, either string or *regex
// and throws an error with line number
func AssertMatchRegex(t *testing.T, value string, regex interface{}) {
matchRegexSkip(t, 2, value, regex)
}
// AssertNotMatchRegex validates that value matches the regex, either string or *regex
// and throws an error with line number
func AssertNotMatchRegex(t *testing.T, value string, regex interface{}) {
notMatchRegexSkip(t, 2, value, regex)
}
// AssertPanic validates that the function should panic
func AssertPanic(t *testing.T, fn func()) {
panicSkip(t, 2, fn)
}
// AssertPanicMatches validates that the panic output of running fn matches the supplied string
func AssertPanicMatches(t *testing.T, fn func(), matches string) {
panicMatchesSkip(t, 2, fn, matches)
}
func AssertIsNil(t *testing.T, actual interface{}) {
equalSkip(t, 2, nil, actual)
}
func AssertIsNotNil(t *testing.T, actual interface{}) {
notEqualSkip(t, 2, nil, actual)
}
func AssertTrue(t *testing.T, actual bool) {
equalSkip(t, 2, true, actual)
}
func AssertFalse(t *testing.T, actual bool) {
equalSkip(t, 2, false, actual)
}
func AssertInMap(t *testing.T, m interface{}, key interface{}) {
inMapSkip(t, 2, m, key)
}
func AssertIsError(t *testing.T, err error) {
notEqualSkip(t, 2, nil, err)
}
func AssertIsNotError(t *testing.T, err error) {
equalSkip(t, 2, nil, err)
}