urfave-cli/helpers_test.go

33 lines
655 B
Go
Raw Normal View History

package cli
2013-07-20 22:50:13 +00:00
import (
"os"
2013-07-20 22:50:13 +00:00
"reflect"
"runtime"
"strings"
2013-07-20 22:50:13 +00:00
"testing"
)
var (
wd, _ = os.Getwd()
)
func init() {
2019-09-15 09:22:46 +00:00
_ = os.Setenv("CLI_TEMPLATE_REPANIC", "1")
}
2013-07-20 22:50:13 +00:00
func expect(t *testing.T, a interface{}, b interface{}) {
_, fn, line, _ := runtime.Caller(1)
fn = strings.Replace(fn, wd+"/", "", -1)
if !reflect.DeepEqual(a, b) {
t.Errorf("(%s:%d) Expected %v (type %v) - Got %v (type %v)", fn, line, b, reflect.TypeOf(b), a, reflect.TypeOf(a))
2013-07-20 22:50:13 +00:00
}
}
func refute(t *testing.T, a interface{}, b interface{}) {
if reflect.DeepEqual(a, b) {
2013-07-20 22:50:13 +00:00
t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}