From b209f943d2611fa4ac2dd9c64b1a014182b59a3d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Mar 2023 12:33:02 +0100 Subject: Replace {add,sub,mul}_overload with q{Add,Sub,Mul}Overload These APIs started out as private APIs in qnumeric_p.h, but have since been made pseudo-public in qnumeric.h. The qnumeric_p.h versions just forward to the qnumeric.h ones, so just use the latter. This is in preparation of removing the {add,sub,mul}_overflow versions, which, despite being defined in the unnamed namespace, don't sport the q prefix, so potentially clash with global symbols. The change is a simple textual search and replace, manually excluding qnumeric_p.h. Picking to 6.5 to avoid cherry-pick conflicts going forward. Pick-to: 6.6 6.5 Change-Id: Ic0f7c92f7c47923317109e8a9dc06fa66bdff2c2 Reviewed-by: Fabian Kosmale --- .../auto/corelib/global/qnumeric/tst_qnumeric.cpp | 80 +++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'tests/auto/corelib/global/qnumeric') diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 03acf5c074..2fffedf492 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -434,33 +434,33 @@ template static void addOverflow_template() #define ADD_COMPARE_NONOVF(v1, v2, expected) \ do { \ - QCOMPARE(add_overflow(Int(v1), Int(v2), &r), false); \ + QCOMPARE(qAddOverflow(Int(v1), Int(v2), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(add_overflow(Int(v1), (std::integral_constant()), &r), false); \ + QCOMPARE(qAddOverflow(Int(v1), (std::integral_constant()), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(add_overflow(Int(v1), &r), false); \ + QCOMPARE(qAddOverflow(Int(v1), &r), false); \ QCOMPARE(r, Int(expected)); \ } while (false) #define ADD_COMPARE_OVF(v1, v2) \ do { \ - QCOMPARE(add_overflow(Int(v1), Int(v2), &r), true); \ - QCOMPARE(add_overflow(Int(v1), (std::integral_constant()), &r), true); \ - QCOMPARE(add_overflow(Int(v1), &r), true); \ + QCOMPARE(qAddOverflow(Int(v1), Int(v2), &r), true); \ + QCOMPARE(qAddOverflow(Int(v1), (std::integral_constant()), &r), true); \ + QCOMPARE(qAddOverflow(Int(v1), &r), true); \ } while (false) #define SUB_COMPARE_NONOVF(v1, v2, expected) \ do { \ - QCOMPARE(sub_overflow(Int(v1), Int(v2), &r), false); \ + QCOMPARE(qSubOverflow(Int(v1), Int(v2), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(sub_overflow(Int(v1), (std::integral_constant()), &r), false); \ + QCOMPARE(qSubOverflow(Int(v1), (std::integral_constant()), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(sub_overflow(Int(v1), &r), false); \ + QCOMPARE(qSubOverflow(Int(v1), &r), false); \ QCOMPARE(r, Int(expected)); \ } while (false) #define SUB_COMPARE_OVF(v1, v2) \ do { \ - QCOMPARE(sub_overflow(Int(v1), Int(v2), &r), true); \ - QCOMPARE(sub_overflow(Int(v1), (std::integral_constant()), &r), true); \ - QCOMPARE(sub_overflow(Int(v1), &r), true); \ + QCOMPARE(qSubOverflow(Int(v1), Int(v2), &r), true); \ + QCOMPARE(qSubOverflow(Int(v1), (std::integral_constant()), &r), true); \ + QCOMPARE(qSubOverflow(Int(v1), &r), true); \ } while (false) // basic values @@ -611,18 +611,18 @@ template static void mulOverflow_template() #define MUL_COMPARE_NONOVF(v1, v2, expected) \ do { \ - QCOMPARE(mul_overflow(Int(v1), Int(v2), &r), false); \ + QCOMPARE(qMulOverflow(Int(v1), Int(v2), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(mul_overflow(Int(v1), (std::integral_constant()), &r), false); \ + QCOMPARE(qMulOverflow(Int(v1), (std::integral_constant()), &r), false); \ QCOMPARE(r, Int(expected)); \ - QCOMPARE(mul_overflow(Int(v1), &r), false); \ + QCOMPARE(qMulOverflow(Int(v1), &r), false); \ QCOMPARE(r, Int(expected)); \ } while (false); #define MUL_COMPARE_OVF(v1, v2) \ do { \ - QCOMPARE(mul_overflow(Int(v1), Int(v2), &r), true); \ - QCOMPARE(mul_overflow(Int(v1), (std::integral_constant()), &r), true); \ - QCOMPARE(mul_overflow(Int(v1), &r), true); \ + QCOMPARE(qMulOverflow(Int(v1), Int(v2), &r), true); \ + QCOMPARE(qMulOverflow(Int(v1), (std::integral_constant()), &r), true); \ + QCOMPARE(qMulOverflow(Int(v1), &r), true); \ } while (false); // basic multiplications @@ -723,28 +723,28 @@ void tst_QNumeric::signedOverflow() const int maxInt = std::numeric_limits::max(); int r; - QCOMPARE(add_overflow(minInt + 1, int(-1), &r), false); - QCOMPARE(add_overflow(minInt, int(-1), &r), true); - QCOMPARE(add_overflow(minInt, minInt, &r), true); - QCOMPARE(add_overflow(maxInt - 1, int(1), &r), false); - QCOMPARE(add_overflow(maxInt, int(1), &r), true); - QCOMPARE(add_overflow(maxInt, maxInt, &r), true); - - QCOMPARE(sub_overflow(minInt + 1, int(1), &r), false); - QCOMPARE(sub_overflow(minInt, int(1), &r), true); - QCOMPARE(sub_overflow(minInt, maxInt, &r), true); - QCOMPARE(sub_overflow(maxInt - 1, int(-1), &r), false); - QCOMPARE(sub_overflow(maxInt, int(-1), &r), true); - QCOMPARE(sub_overflow(maxInt, minInt, &r), true); - - QCOMPARE(mul_overflow(minInt, int(1), &r), false); - QCOMPARE(mul_overflow(minInt, int(-1), &r), true); - QCOMPARE(mul_overflow(minInt, int(2), &r), true); - QCOMPARE(mul_overflow(minInt, minInt, &r), true); - QCOMPARE(mul_overflow(maxInt, int(1), &r), false); - QCOMPARE(mul_overflow(maxInt, int(-1), &r), false); - QCOMPARE(mul_overflow(maxInt, int(2), &r), true); - QCOMPARE(mul_overflow(maxInt, maxInt, &r), true); + QCOMPARE(qAddOverflow(minInt + 1, int(-1), &r), false); + QCOMPARE(qAddOverflow(minInt, int(-1), &r), true); + QCOMPARE(qAddOverflow(minInt, minInt, &r), true); + QCOMPARE(qAddOverflow(maxInt - 1, int(1), &r), false); + QCOMPARE(qAddOverflow(maxInt, int(1), &r), true); + QCOMPARE(qAddOverflow(maxInt, maxInt, &r), true); + + QCOMPARE(qSubOverflow(minInt + 1, int(1), &r), false); + QCOMPARE(qSubOverflow(minInt, int(1), &r), true); + QCOMPARE(qSubOverflow(minInt, maxInt, &r), true); + QCOMPARE(qSubOverflow(maxInt - 1, int(-1), &r), false); + QCOMPARE(qSubOverflow(maxInt, int(-1), &r), true); + QCOMPARE(qSubOverflow(maxInt, minInt, &r), true); + + QCOMPARE(qMulOverflow(minInt, int(1), &r), false); + QCOMPARE(qMulOverflow(minInt, int(-1), &r), true); + QCOMPARE(qMulOverflow(minInt, int(2), &r), true); + QCOMPARE(qMulOverflow(minInt, minInt, &r), true); + QCOMPARE(qMulOverflow(maxInt, int(1), &r), false); + QCOMPARE(qMulOverflow(maxInt, int(-1), &r), false); + QCOMPARE(qMulOverflow(maxInt, int(2), &r), true); + QCOMPARE(qMulOverflow(maxInt, maxInt, &r), true); } QTEST_APPLESS_MAIN(tst_QNumeric) -- cgit v1.2.3