You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation states that if the argument of .TypeOf(...) is nil, the result is nil.
Here are example tests that fail:
funcTestOKValidationWithNullValue(t*testing.T) {
expectedValue:= []byte("{"+"\"active\": null"+"}")
actualValue:= []byte("{"+"\"active\": null"+"}")
// we ignore the recorder log because the order of the elements is always differenttestComparator(t, expectedValue, actualValue, []string{}, "")
}
funcTestErrorValidationWithNullActualValue(t*testing.T) {
expectedValue:= []byte("{"+"\"active\": true"+"}")
actualValue:= []byte("{"+"\"active\": null"+"}")
// we ignore the recorder log because the order of the elements is always differenttestComparator(t, expectedValue, actualValue, []string{}, "")
}
funcTestErrorValidationWithNullExpectedValue(t*testing.T) {
expectedValue:= []byte("{"+"\"name\": null,"+"}")
actualValue:= []byte("{"+" \"name\": \"Bruce Wayne\","+"}")
// we ignore the recorder log because the order of the elements is always differenttestComparator(t, expectedValue, actualValue, []string{}, "")
}
funcTestNullExpectedValue(t*testing.T) {
expectedErrors:= []string{
...
}
expectedValue:= []byte("{"+"\"aliases\": ["+"null"+"]"+"}")
actualValue:= []byte("{"+"\"aliases\": ["+"\"Batman\""+"]"+"}")
expectedRecorderLog:="{\n"+"}\n"testComparator(t, expectedValue, actualValue, expectedErrors, expectedRecorderLog)
}
funcTestNullActualValue(t*testing.T) {
expectedErrors:= []string{
...
}
expectedValue:= []byte("{"+"\"aliases\": ["+"\"Batman\""+"]"+"}")
actualValue:= []byte("{"+"\"aliases\": ["+"null"+"]"+"}")
expectedRecorderLog:="{\n"+"}\n"testComparator(t, expectedValue, actualValue, expectedErrors, expectedRecorderLog)
}
The text was updated successfully, but these errors were encountered:
A null pointer is caused when a JSON payload (expected or actual) contains 'null' as value. This is most probably caused by these lines:
The documentation states that if the argument of .TypeOf(...) is nil, the result is nil.
Here are example tests that fail:
The text was updated successfully, but these errors were encountered: