From 7d74404325118bb1551c38b3bae418b42db843a1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 13 Mar 2019 19:15:27 +0100 Subject: Replace a misguided test with a valid one The code had min and max of an integral type and tested min + min / 2, which naturally overflowed, provoking a compiler warning. The test was meant to be testing min - min / 2; but min is even, so this is just min / 2; and doubling that won't overflow (which is what the test is about). As it happens, min + min / 2 is in fact max - max / 2, which *would* be a good value to test, since max is odd. So add a test for that and remove the broken test. Change-Id: Iec34acbf0d5d7993d41ff844875dc10480b8eb1f Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp') diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index e567e465f7..0a84b1fdd8 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -508,13 +508,13 @@ template static void mulOverflow_template() QCOMPARE(mul_overflow(Int(max / 2), Int(3), &r), true); QCOMPARE(mul_overflow(mid1, Int(mid2 + 1), &r), true); QCOMPARE(mul_overflow(Int(max / 2 + 2), Int(2), &r), true); + QCOMPARE(mul_overflow(Int(max - max / 2), Int(2), &r), true); QCOMPARE(mul_overflow(Int(1ULL << (std::numeric_limits::digits - 1)), Int(2), &r), true); if (min) { QCOMPARE(mul_overflow(min, Int(2), &r), true); QCOMPARE(mul_overflow(Int(min / 2), Int(3), &r), true); QCOMPARE(mul_overflow(Int(min / 2 - 1), Int(2), &r), true); - QCOMPARE(mul_overflow(Int(min + min/2), Int(2), &r), true); } #endif } -- cgit v1.2.3