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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
package expectate_test
import (
"testing"
"time"
"github.com/gomagedon/expectate"
)
var notToEqualTests = []ExpectTest{
{
name: "2 equals 2",
subject: 2,
object: 2,
expectedFailure: "2 equals 2",
},
{
name: "2 does not equal 3",
subject: 2,
object: 3,
expectedFailure: "",
},
{
name: "'foo' equals 'foo'",
subject: "foo",
object: "foo",
expectedFailure: "'foo' equals 'foo'",
},
{
name: "'foo' does not equal 'bar'",
subject: "foo",
object: "bar",
expectedFailure: "",
},
{
name: "pointer to struct equals pointer to copy of struct",
subject: &Person{
Name: "John Doe",
Age: 30,
Job: "Electrician",
Birthday: time.Date(1990, time.January, 1, 0, 0, 0, 0, time.UTC),
},
object: &Person{
Name: "John Doe",
Age: 30,
Job: "Electrician",
Birthday: time.Date(1990, time.January, 1, 0, 0, 0, 0, time.UTC),
},
expectedFailure: "&{John Doe 30 Electrician 1990-01-01 00:00:00 +0000 UTC} equals &{John Doe 30 Electrician 1990-01-01 00:00:00 +0000 UTC}",
},
}
func TestNotToEqual(t *testing.T) {
for _, test := range notToEqualTests {
t.Run(test.name, func(t *testing.T) {
mockTestingT := new(MockTestingT)
expect := expectate.Expect(mockTestingT)
expect(test.subject).NotToEqual(test.object)
if mockTestingT.FataledWith != test.expectedFailure {
t.Fatal("Expected:", test.expectedFailure,
"\nGot:", mockTestingT.FataledWith)
}
})
}
}
|