diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-03-01 22:24:43 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-03-05 06:00:18 +0100 |
commit | 9ec61d446030da35fcc7c809c5d736397a99258e (patch) | |
tree | 573376bd3ceb633b369ff3fc939497386337dc36 /tests/auto/gui/painting | |
parent | 47df0eb5131a5fc0decd049bd3f9eefeb26276df (diff) |
Port QPathClipper test away from home-grown QCOMPARE
Use a scope guard to print debug info in case of an early return.
Silences clang warning about sprintf being unsafe and deprecated.
Change-Id: Idcbfde1a6f2eb1143f51c1e5ecedbf3fe90d8ec8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r-- | tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp index e93d0f4ba1..4ecfa24105 100644 --- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp @@ -470,15 +470,19 @@ void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::O break; } - if (expected != inResult) { - char str[256]; - const char *opStr = - op == QPathClipper::BoolAnd ? "and" : - op == QPathClipper::BoolOr ? "or" : "sub"; - sprintf(str, "Expected: %d, actual: %d, subject: %d, clip: %d, op: %s\n", - int(expected), int(inResult), subjectIndex, clipIndex, opStr); - QFAIL(str); - } + auto failLogger = qScopeGuard([&]{ + qCritical().noquote().nospace() + << "\n\tExpected: " << expected + << "\n\tActual: " << inResult + << "\n\tSubject: " << subjectIndex + << "\n\tClip: " << clipIndex + << "\n\tOp: " << (op == QPathClipper::BoolAnd + ? "and" + : op == QPathClipper::BoolOr + ? "or" : "sub"); + }); + QCOMPARE(inResult, expected); + failLogger.dismiss(); } } |