From b888bc09ce33a91800cb2119a52097897f3d62d1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Feb 2025 22:50:27 -0800 Subject: [PATCH] tst_QGetPutEnv: use a lambda instead of a macro Neater and more debuggable. This code was added in Qt 5.4, before we could use C++11. Pick-to: 6.9 6.8 6.5 6.2 5.15 Change-Id: Icd8acccb4a9ae1f500e7fffdc4d4fc7c310cbb89 Reviewed-by: Marc Mutz --- .../global/qgetputenv/tst_qgetputenv.cpp | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 9f9fc8f534e..126fdc8ae6e 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -142,29 +142,30 @@ void tst_QGetPutEnv::intValue_data() QTest::newRow("junk-heading") << QByteArray("x1") << 0 << false; QTest::newRow("junk-trailing") << QByteArray("1x") << 0 << false; -#define ROW(x, i, b) \ - QTest::newRow(#x) << QByteArray(#x) << (i) << (b) - ROW(auto, 0, false); - ROW(1auto, 0, false); - ROW(0, 0, true); - ROW(+0, 0, true); - ROW(1, 1, true); - ROW(+1, 1, true); - ROW(09, 0, false); - ROW(010, 8, true); - ROW(0x10, 16, true); - ROW(0x, 0, false); - ROW(0xg, 0, false); - ROW(0x1g, 0, false); - ROW(000000000000000000000000000000000000000000000000001, 0, false); - ROW(+000000000000000000000000000000000000000000000000001, 0, false); - ROW(000000000000000000000000000000000000000000000000001g, 0, false); - ROW(-0, 0, true); - ROW(-1, -1, true); - ROW(-010, -8, true); - ROW(-000000000000000000000000000000000000000000000000001, 0, false); - // ROW(0xffffffff, -1, true); // could be expected, but not how QByteArray::toInt() works - ROW(0xffffffff, 0, false); + auto addRow = [](const char *text, int expected, bool ok) { + QTest::newRow(text) << QByteArray(text) << expected << ok; + }; + addRow("auto", 0, false); + addRow("1auto", 0, false); + addRow("0", 0, true); + addRow("+0", 0, true); + addRow("1", 1, true); + addRow("+1", 1, true); + addRow("09", 0, false); + addRow("010", 8, true); + addRow("0x10", 16, true); + addRow("0x", 0, false); + addRow("0xg", 0, false); + addRow("0x1g", 0, false); + addRow("000000000000000000000000000000000000000000000000001", 0, false); + addRow("+000000000000000000000000000000000000000000000000001", 0, false); + addRow("000000000000000000000000000000000000000000000000001g", 0, false); + addRow("-0", 0, true); + addRow("-1", -1, true); + addRow("-010", -8, true); + addRow("-000000000000000000000000000000000000000000000000001", 0, false); + // addRow("0xffffffff", -1, true); // could be expected, but not how QByteArray::toInt() works + addRow("0xffffffff", 0, false); auto addNumWithBase = [](qlonglong num, int base) { QByteArray text;