mirror of https://github.com/stretchr/testify.git
table-ify Exactly
parent
9ffb85bbec
commit
590942c47f
|
@ -474,6 +474,12 @@ func TestFalse(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestCase struct {
|
||||||
|
expected interface{}
|
||||||
|
actual interface{}
|
||||||
|
result bool
|
||||||
|
}
|
||||||
|
|
||||||
func TestExactly(t *testing.T) {
|
func TestExactly(t *testing.T) {
|
||||||
|
|
||||||
mockT := new(testing.T)
|
mockT := new(testing.T)
|
||||||
|
@ -482,30 +488,21 @@ func TestExactly(t *testing.T) {
|
||||||
b := float64(1)
|
b := float64(1)
|
||||||
c := float32(1)
|
c := float32(1)
|
||||||
d := float32(2)
|
d := float32(2)
|
||||||
|
cases := []TestCase{
|
||||||
if Exactly(mockT, a, b) {
|
{a, b, false},
|
||||||
t.Error("Exactly should return false")
|
{a, d, false},
|
||||||
}
|
{a, c, true},
|
||||||
if Exactly(mockT, a, d) {
|
{nil, a, false},
|
||||||
t.Error("Exactly should return false")
|
{a, nil, false},
|
||||||
}
|
|
||||||
if !Exactly(mockT, a, c) {
|
|
||||||
t.Error("Exactly should return true")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if Exactly(mockT, nil, a) {
|
for _, c := range cases {
|
||||||
t.Error("Exactly should return false")
|
res := Exactly(mockT, c.expected, c.actual)
|
||||||
}
|
|
||||||
if Exactly(mockT, a, nil) {
|
|
||||||
t.Error("Exactly should return false")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if res != c.result {
|
||||||
|
t.Errorf("Exactly(%v, %v) should return %v", c.expected, c.actual, c.result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TestCase struct {
|
|
||||||
expected interface{}
|
|
||||||
actual interface{}
|
|
||||||
result bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNotEqual(t *testing.T) {
|
func TestNotEqual(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue