From fcca13200fcd0f96749bbe4bea25f2cbb6b5742c Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 23 Feb 2022 11:49:01 -0800 Subject: [PATCH] ICU-21900 Fix issues found while running samples. --- icu4c/source/test/intltest/incaltst.cpp | 2 +- icu4c/source/test/intltest/numbertest_decimalquantity.cpp | 4 ++-- icu4c/source/test/intltest/plurults.cpp | 6 +++--- icu4c/source/test/intltest/ustrtest.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp index ad75f185f63..250b61c7ac0 100644 --- a/icu4c/source/test/intltest/incaltst.cpp +++ b/icu4c/source/test/intltest/incaltst.cpp @@ -988,7 +988,7 @@ void IntlCalendarTest::TestConsistencyEthiopicAmeteAlem() { } void IntlCalendarTest::checkConsistency(const char* locale) { // Check 2.5 years in quick mode and 8000 years in exhaustive mode. - int32_t numOfDaysToTest = (quick ? 2.5 : 8000) * 365; + int32_t numOfDaysToTest = static_cast((quick ? 2.5 : 8000) * 365); constexpr int32_t msInADay = 1000*60*60*24; std::string msg("TestConsistency"); IcuTestErrorCode status(*this, (msg + locale).c_str()); diff --git a/icu4c/source/test/intltest/numbertest_decimalquantity.cpp b/icu4c/source/test/intltest/numbertest_decimalquantity.cpp index 7403dda7e75..5e2d28fd415 100644 --- a/icu4c/source/test/intltest/numbertest_decimalquantity.cpp +++ b/icu4c/source/test/intltest/numbertest_decimalquantity.cpp @@ -317,7 +317,7 @@ void DecimalQuantityTest::testUseApproximateDoubleWhenAble() { {1.235, 3, RoundingMode::UNUM_ROUND_CEILING, true}}; UErrorCode status = U_ZERO_ERROR; - for (TestCase cas : cases) { + for (const TestCase& cas : cases) { DecimalQuantity fq; fq.setToDouble(cas.d); assertTrue("Should be using approximate double", !fq.isExplicitExactDouble()); @@ -623,7 +623,7 @@ void DecimalQuantityTest::testScientificAndCompactSuppressedExponent() { // test the actual computed values of the plural operands double expectedNOperand = cas.expectedDouble; - double expectedIOperand = cas.expectedLong; + double expectedIOperand = static_cast(cas.expectedLong); double expectedEOperand = cas.expectedSuppressedScientificExponent; double expectedCOperand = cas.expectedSuppressedCompactExponent; double actualNOperand = dq.getPluralOperand(PLURAL_OPERAND_N); diff --git a/icu4c/source/test/intltest/plurults.cpp b/icu4c/source/test/intltest/plurults.cpp index 9131d370317..54cc77a0c9e 100644 --- a/icu4c/source/test/intltest/plurults.cpp +++ b/icu4c/source/test/intltest/plurults.cpp @@ -919,7 +919,7 @@ PluralRulesTest::testDoubleValue() { const int64_t inputNum = cas.inputNum; const double expVal = cas.expVal; - FixedDecimal fd(inputNum); + FixedDecimal fd(static_cast(inputNum)); UnicodeString message(u"FixedDecimal::doubleValue() for" + Int64ToUnicodeString(inputNum)); assertEquals(message, expVal, fd.doubleValue()); } @@ -963,7 +963,7 @@ PluralRulesTest::testLongValue() { const int64_t inputNum = cas.inputNum; const int64_t expVal = cas.expVal; - FixedDecimal fd(inputNum); + FixedDecimal fd(static_cast(inputNum)); UnicodeString message(u"FixedDecimal::longValue() for" + Int64ToUnicodeString(inputNum)); assertEquals(message, expVal, fd.longValue()); } @@ -982,7 +982,7 @@ PluralRulesTest::testLongValue() { const double inputNum = cas.inputNum; const int64_t expVal = cas.expVal; - FixedDecimal fd(inputNum); + FixedDecimal fd(static_cast(inputNum)); UnicodeString message(u"FixedDecimal::longValue() for" + DoubleToUnicodeString(inputNum)); assertEquals(message, expVal, fd.longValue()); } diff --git a/icu4c/source/test/intltest/ustrtest.cpp b/icu4c/source/test/intltest/ustrtest.cpp index 11bbb6e27af..309a29713d7 100644 --- a/icu4c/source/test/intltest/ustrtest.cpp +++ b/icu4c/source/test/intltest/ustrtest.cpp @@ -2364,7 +2364,7 @@ void UnicodeStringTest::TestLargeAppend() { } else if (total <= INT32_MAX) { // Check that a string of exactly the maximum size works UnicodeString str2; - int32_t remain = INT32_MAX - total; + int32_t remain = static_cast(INT32_MAX - total); char16_t *buf2 = str2.getBuffer(remain); if (buf2 == nullptr) { // if somehow memory allocation fail, return the test