-
Notifications
You must be signed in to change notification settings - Fork 1
/
hamcrest_endswith_test.go
48 lines (45 loc) · 1.19 KB
/
hamcrest_endswith_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
package assert
import "testing"
func TestEndswith(t *testing.T) {
{
err := AssertThat("hello world", Endswith("world"))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat("hello world", Endswith("hello"))
if err == nil {
t.Fatal("expect error")
}
}
{
err := AssertThat("hello world", Endswith("hello"))
expectedValue := "expected <hello world> ends with <hello>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat("hello world", Endswith("hello").Message("msg"))
expectedValue := "msg, expected <hello world> ends with <hello>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
}
func TestEndswithTypeMissmatch(t *testing.T) {
{
err := AssertThat([]byte{}, Endswith("world"))
if err == nil {
t.Fatal("expect error")
}
}
{
err := AssertThat([]byte{}, Endswith("world"))
expectedValue := "expected type string but got []uint8"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
}