-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
be_example_test.go
45 lines (36 loc) · 1.02 KB
/
be_example_test.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
package be_test
import (
"errors"
"github.com/carlmjohnson/be"
)
func Example() {
// mock *testing.T for example purposes
t := be.Relaxed(&mockingT{})
be.Equal(t, "hello", "world") // bad
be.Equal(t, "goodbye", "goodbye") // good
be.Unequal(t, "hello", "world") // good
be.Unequal(t, "goodbye", "goodbye") // bad
s := []int{1, 2, 3}
be.AllEqual(t, []int{1, 2, 3}, s) // good
be.AllEqual(t, []int{3, 2, 1}, s) // bad
var err error
be.NilErr(t, err) // good
be.Nonzero(t, err) // bad
err = errors.New("(O_o)")
be.NilErr(t, err) // bad
be.Nonzero(t, err) // good
type mytype string
var mystring mytype = "hello, world"
be.In(t, "world", mystring) // good
be.In(t, "World", mystring) // bad
be.NotIn(t, "\x01", []byte("\a\b\x00\r\t")) // good
be.NotIn(t, "\x00", []byte("\a\b\x00\r\t")) // bad
// Output:
// want: hello; got: world
// got: goodbye
// want: [3 2 1]; got: [1 2 3]
// got: <nil>
// got: (O_o)
// "World" not in "hello, world"
// "\x00" in "\a\b\x00\r\t"
}