-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhamcrest_ge_test.go
52 lines (50 loc) · 1.25 KB
/
hamcrest_ge_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 TestGe(t *testing.T) {
{
err := AssertThat(3, Ge(2))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(3, Ge(3))
if err != nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(2, Ge(3))
if err == nil {
t.Fatal("expect nil")
}
}
{
err := AssertThat(2, Ge(3))
expectedValue := "expected <2> is greater or equal than <3>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(2, Ge(3).Message("msg"))
expectedValue := "msg, expected <2> is greater or equal than <3>"
if err.Error() != expectedValue {
t.Fatalf("error message missmatch, expected '%v' but was '%v'", expectedValue, err.Error())
}
}
{
err := AssertThat(2.1, Ge(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, Ge(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())
}
}
}