]> granicus.if.org Git - icu/commitdiff
ICU-21900 Fix issues found while running samples.
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 23 Feb 2022 19:49:01 +0000 (11:49 -0800)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Wed, 23 Feb 2022 22:58:07 +0000 (14:58 -0800)
icu4c/source/test/intltest/incaltst.cpp
icu4c/source/test/intltest/numbertest_decimalquantity.cpp
icu4c/source/test/intltest/plurults.cpp
icu4c/source/test/intltest/ustrtest.cpp

index ad75f185f632cae9e70f0ab116639710575b0448..250b61c7ac09cb40f9ad1a7d2bdbc5667fdfc87b 100644 (file)
@@ -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<int32_t>((quick ? 2.5 : 8000) * 365);
     constexpr int32_t msInADay = 1000*60*60*24;
     std::string msg("TestConsistency");
     IcuTestErrorCode status(*this, (msg + locale).c_str());
index 7403dda7e75b1033cc61daf95817f6bd3ddf8562..5e2d28fd4157c4d938d9489ddc55cb60a77ff21e 100644 (file)
@@ -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<double>(cas.expectedLong);
         double expectedEOperand = cas.expectedSuppressedScientificExponent;
         double expectedCOperand = cas.expectedSuppressedCompactExponent;
         double actualNOperand = dq.getPluralOperand(PLURAL_OPERAND_N);
index 9131d370317f4670e16c9fadab71b07991139269..54cc77a0c9e291a55b99931793734957e4d5e11c 100644 (file)
@@ -919,7 +919,7 @@ PluralRulesTest::testDoubleValue() {
         const int64_t inputNum = cas.inputNum;
         const double expVal = cas.expVal;
 
-        FixedDecimal fd(inputNum);
+        FixedDecimal fd(static_cast<double>(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<double>(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<double>(inputNum));
         UnicodeString message(u"FixedDecimal::longValue() for" + DoubleToUnicodeString(inputNum));
         assertEquals(message, expVal, fd.longValue());
     }
index 11bbb6e27af58272f8bfcfe6aa7d190166c5bd8b..309a29713d718f197ba15be0033f08f655b908df 100644 (file)
@@ -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_t>(INT32_MAX - total);
             char16_t *buf2 = str2.getBuffer(remain);
             if (buf2 == nullptr) {
                 // if somehow memory allocation fail, return the test