From 0a1352ee674c4b3f7619e38e8380b7010fb20aaa Mon Sep 17 00:00:00 2001 From: gnrunge Date: Mon, 22 Feb 2021 16:36:19 -0800 Subject: [PATCH] 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. --- icu4c/source/test/intltest/units_test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/icu4c/source/test/intltest/units_test.cpp b/icu4c/source/test/intltest/units_test.cpp index 3a8522bf46f..a18e751e470 100644 --- a/icu4c/source/test/intltest/units_test.cpp +++ b/icu4c/source/test/intltest/units_test.cpp @@ -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(), -- 2.40.0