-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshould_test.go
More file actions
61 lines (46 loc) · 794 Bytes
/
should_test.go
File metadata and controls
61 lines (46 loc) · 794 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package should_test
import (
"errors"
"fmt"
"reflect"
"testing"
"qlova.org/should"
)
func Test_Panic(t *testing.T) {
should.Panic(func() {
panic(nil)
}).Test(t)
should.Error(should.Panic(func() {})).Test(t)
}
func Test_NotPanic(t *testing.T) {
should.NotPanic(
func() {},
).Test(t)
should.Error(
should.NotPanic(nil),
).Test(t)
}
func Test_Error(t *testing.T) {
var e interface{} = nil
fmt.Println(reflect.TypeOf(e) == nil)
should.Error(
errors.New(""),
).Test(t)
should.Error(
should.Error(error(nil)),
).Test(t)
}
func Test_NotError(t *testing.T) {
should.NotError(
nil,
).Test(t)
should.Error(
should.NotError(errors.New("")),
).Test(t)
}
func Test_Be(t *testing.T) {
should.Be(3)(3).Test(t)
should.Error(
should.Be(3)(1),
).Test(t)
}