-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhamcrest_notnilvalue_test.go
51 lines (49 loc) · 1 KB
/
hamcrest_notnilvalue_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
46
47
48
49
50
51
package assert
import "testing"
func TestNotNilValue(t *testing.T) {
{
err := AssertThat(t, NotNilValue())
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(0, NotNilValue())
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat("", NotNilValue())
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(nil, NotNilValue())
if err == nil {
t.Fatal("expect nil")
}
}
{
var foo *string
err := AssertThat(foo, NotNilValue())
if err == nil {
t.Fatal("expect not nil")
}
}
{
err := AssertThat(nil, NotNilValue())
expectedValue := "expected not nil value"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(nil, NotNilValue().Message("msg"))
expectedValue := "msg, expected not nil value"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
}