go-json/helper_test.go

37 lines
810 B
Go
Raw Normal View History

2020-04-24 14:48:15 +03:00
package json_test
2023-08-21 18:19:19 +03:00
import (
"reflect"
"testing"
)
2020-04-24 14:48:15 +03:00
func assertErr(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Fatalf("%+v", err)
}
}
func assertEq(t *testing.T, msg string, exp interface{}, act interface{}) {
t.Helper()
if exp != act {
t.Fatalf("failed to test for %s. exp=[%v] but act=[%v]", msg, exp, act)
}
}
2020-08-08 07:20:42 +03:00
func assertNeq(t *testing.T, msg string, exp interface{}, act interface{}) {
t.Helper()
if exp == act {
t.Fatalf("failed to test for %s. expected value is not [%v] but got same value", msg, act)
}
}
2023-08-21 18:19:19 +03:00
func assertIsType(t *testing.T, msg string, exp interface{}, act interface{}) {
t.Helper()
expType := reflect.TypeOf(exp)
actType := reflect.TypeOf(act)
if expType != actType {
t.Fatalf("failed to test for %s. exp[%v] bug act=[%v]", msg, expType, actType)
}
}