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
|
// Copyright 2014 Quoc-Viet Nguyen. All rights reserved.
// This software may be modified and distributed under the terms
// of the BSD license. See the LICENSE file for details.
package test
import (
"runtime"
"strings"
"testing"
)
func AssertEquals(t *testing.T, expected, actual interface{}) {
_, file, line, ok := runtime.Caller(1)
if !ok {
file = "???"
line = 0
} else {
// Get file name only
idx := strings.LastIndex(file, "/")
if idx >= 0 {
file = file[idx+1:]
}
}
if expected != actual {
t.Logf("%s:%d: Expected: %+v (%T), actual: %+v (%T)", file, line,
expected, expected, actual, actual)
t.FailNow()
}
}
|