-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhamcrest_startswith_test.go
More file actions
48 lines (45 loc) · 1.21 KB
/
hamcrest_startswith_test.go
File metadata and controls
48 lines (45 loc) · 1.21 KB
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 TestStartswith(t *testing.T) {
{
err := AssertThat("hello world", Startswith("hello"))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat("hello world", Startswith("world"))
if err == nil {
t.Fatal("expect error")
}
}
{
err := AssertThat("hello world", Startswith("world"))
expectedValue := "expected <hello world> starts with <world>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat("hello world", Startswith("world").Message("msg"))
expectedValue := "msg, expected <hello world> starts with <world>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
}
func TestStartswithTypeMissmatch(t *testing.T) {
{
err := AssertThat([]byte{}, Startswith("world"))
if err == nil {
t.Fatal("expect error")
}
}
{
err := AssertThat([]byte{}, Startswith("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())
}
}
}