ICU-21502 Adds status checks to test to prevent segementation fault when

test runs with ICU stub data only.

ICU-21502 Review comments worked in.
This commit is contained in:
gnrunge 2021-02-22 16:36:19 -08:00 committed by Norbert Runge
parent aa9f5bc279
commit 0a1352ee67

View file

@ -708,10 +708,26 @@ void UnitsTest::testComplexUnitsConverterSorting() {
for (const auto &testCase : testCases) {
MeasureUnitImpl inputImpl = MeasureUnitImpl::forIdentifier(testCase.input, status);
if (status.errIfFailureAndReset()) {
continue;
}
MeasureUnitImpl outputImpl = MeasureUnitImpl::forIdentifier(testCase.output, status);
if (status.errIfFailureAndReset()) {
continue;
}
ComplexUnitsConverter converter(inputImpl, outputImpl, conversionRates, status);
if (status.errIfFailureAndReset()) {
continue;
}
auto actual = converter.convert(testCase.inputValue, nullptr, status);
if (status.errIfFailureAndReset()) {
continue;
}
if (actual.length() < testCase.expectedCount) {
errln("converter.convert(...) returned too few Measures");
continue;
}
for (int i = 0; i < testCase.expectedCount; i++) {
assertEquals(testCase.msg, testCase.expected[i].getUnit().getIdentifier(),