-
Notifications
You must be signed in to change notification settings - Fork 1
/
hamcrest_le_test.go
52 lines (50 loc) · 1.24 KB
/
hamcrest_le_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
52
package assert
import "testing"
func TestLe(t *testing.T) {
{
err := AssertThat(2, Le(3))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(3, Le(3))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(3, Le(2))
if err == nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(3, Le(2))
expectedValue := "expected <3> is less or equal than <2>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(3, Le(2).Message("msg"))
expectedValue := "msg, expected <3> is less or equal than <2>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(2.1, Le(3))
expectedValue := "expected type int but got float64"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(2.1, Le(3).Message("msg"))
expectedValue := "msg, expected type int but got float64"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
}