vcl/qa/cppunit/vclmaptest.cxx |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 33ebe2177df7b4d5bdcc787f1bb14cec14b71ec9
Author:     Xisco Fauli <[email protected]>
AuthorDate: Thu Mar 5 10:33:53 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Mar 5 15:39:34 2026 +0100

    CppunitTest_vcl_map: fix warning C4309 and C4305
    
    and disable the tests on Windows 32-bit.
    
    lo_tb_master_win started to fail after using 'make check' with
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(105): 
error C2220: the following warning is treated as an error
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(105): 
warning C4310: cast truncates constant value
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(142): 
warning C4305: 'initializing': truncation from '__int64' to 'const tools::Long'
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(142): 
warning C4309: 'initializing': truncation of constant value
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(143): 
warning C4305: 'initializing': truncation from '__int64' to 'const tools::Long'
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(143): 
warning C4309: 'initializing': truncation of constant value
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(161): 
warning C4305: 'initializing': truncation from '__int64' to 'const tools::Long'
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(161): 
warning C4309: 'initializing': truncation of constant value
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(162): 
warning C4305: 'initializing': truncation from '__int64' to 'const tools::Long'
    E:/jenkins/workspace/lo_tb_master_win/vcl/qa/cppunit/vclmaptest.cxx(162): 
warning C4309: 'initializing': truncation of constant value
    
    Change-Id: I7150292d2f39a67501db24d225956fe8167d8426
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201012
    Reviewed-by: Xisco Fauli <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/vclmaptest.cxx b/vcl/qa/cppunit/vclmaptest.cxx
index d186e6426f1e..efb1058d7f42 100644
--- a/vcl/qa/cppunit/vclmaptest.cxx
+++ b/vcl/qa/cppunit/vclmaptest.cxx
@@ -83,7 +83,10 @@ public:
 
     void testIntermediateOverflow()
     {
-        tools::Long nLarge = 1LL << 30;
+// Fails on Windows 32-bit. See include/tools/long.hxx
+#if defined _WIN64 || !defined _WIN32
+        constexpr tools::Long nLarge = static_cast<tools::Long>(1LL << 30);
+        constexpr tools::Long nExpected = 
static_cast<tools::Long>(25400000000);
 
         MapMode aSource(MapUnit::MapInch);
         aSource.SetScaleX(Fraction(nLarge, 1));
@@ -102,7 +105,8 @@ public:
         Point aResult = OutputDevice::LogicToLogic(aPt, aSource, aDest);
 
         // Expected: 10,000,000 inches = 25,400,000,000 100thMM
-        CPPUNIT_ASSERT_EQUAL(tools::Long(25400000000), aResult.X());
+        CPPUNIT_ASSERT_EQUAL(nExpected, aResult.X());
+#endif
     }
 
     void testRoundingBehavior()
@@ -132,6 +136,8 @@ public:
 
     void testOverflowProtectionPositive()
     {
+// Fails on Windows 32-bit. See include/tools/long.hxx
+#if defined _WIN64 || !defined _WIN32
         // Scenario: Convert Inch to MM (IsSimple() == true)
         // Factor: 127 / 5 (1 inch = 25.4 mm = 254/10 = 127/5)
         //
@@ -139,8 +145,9 @@ public:
         // 1. N * 127 > INT64_MAX (9.22e18)  --> Triggers overflow flag in 
o3tl::convert
         // 2. (N * 127) / 5 < INT64_MAX      --> Final result fits in 
tools::Long
 
-        constexpr tools::Long nInput = 100000000000000000LL; // 1e17
-        constexpr tools::Long nExpected = 2540000000000000000LL; // 2.54e18
+        constexpr tools::Long nInput = 
static_cast<tools::Long>(100000000000000000LL); // 1e17
+        constexpr tools::Long nExpected
+            = static_cast<tools::Long>(2540000000000000000LL); // 2.54e18
 
         MapMode aSource(MapUnit::MapInch);
         MapMode aDest(MapUnit::MapMM);
@@ -153,13 +160,16 @@ public:
         Point aResult = OutputDevice::LogicToLogic(aPt, aSource, aDest);
 
         CPPUNIT_ASSERT_EQUAL(nExpected, aResult.X());
+#endif
     }
 
     void testOverflowProtectionNegative()
     {
+// Fails on Windows 32-bit. See include/tools/long.hxx
+#if defined _WIN64 || !defined _WIN32
         // Same as above, but testing negative handling in BigInt path
-        constexpr tools::Long nInput = -100000000000000000LL; // -1e17
-        constexpr tools::Long nExpected = -2540000000000000000LL;
+        constexpr tools::Long nInput = 
static_cast<tools::Long>(-100000000000000000LL); // -1e17
+        constexpr tools::Long nExpected = 
static_cast<tools::Long>(-2540000000000000000LL);
 
         MapMode aSource(MapUnit::MapInch);
         MapMode aDest(MapUnit::MapMM);
@@ -168,6 +178,7 @@ public:
         Point aResult = OutputDevice::LogicToLogic(aPt, aSource, aDest);
 
         CPPUNIT_ASSERT_EQUAL(nExpected, aResult.X());
+#endif
     }
 
     void testRounding()

Reply via email to