-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequal.go
More file actions
42 lines (39 loc) · 729 Bytes
/
Copy pathequal.go
File metadata and controls
42 lines (39 loc) · 729 Bytes
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
package assert
import (
"fmt"
"testing"
)
// Equal asserts that v1 == v2.
//
//nolint:thelper // It's called below.
func Equal[T comparable](tb testing.TB, v1, v2 T, opts ...Option) bool {
ok := v1 == v2
if !ok {
tb.Helper()
Fail(
tb,
"equal",
fmt.Sprintf("not equal:\nv1 = %s\nv2 = %s", ValueStringer(v1), ValueStringer(v2)),
1,
opts...,
)
}
return ok
}
// NotEqual asserts that v1 != v2.
//
//nolint:thelper // It's called below.
func NotEqual[T comparable](tb testing.TB, v1, v2 T, opts ...Option) bool {
ok := v1 != v2
if !ok {
tb.Helper()
Fail(
tb,
"not_equal",
fmt.Sprintf("equal:\nv1 = %s\nv2 = %s", ValueStringer(v1), ValueStringer(v2)),
1,
opts...,
)
}
return ok
}