ICU-21249 Adds error code check to prevent segmentation fault if

See #1356
This commit is contained in:
Norbert Runge 2020-10-02 03:35:10 +00:00
parent 6700602974
commit c0d4065607

View File

@ -65,10 +65,10 @@ static void TestExampleCode() {
// Get the result string:
int32_t len;
const UChar* str = ufmtval_getString(unumrf_resultAsValue(uresult, &ec), &len, &ec);
if (assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE)) {
assertUEquals("Should produce expected string result", u"$3 $5", str);
assertIntEquals("Length should be as expected", u_strlen(str), len);
}
assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE);
assertUEquals("Should produce expected string result", u"$3 $5", str);
int32_t resultLength = str != NULL ? u_strlen(str) : 0;
assertIntEquals("Length should be as expected", resultLength, len);
// Cleanup:
unumrf_close(uformatter);