qt6, test: Handle deprecated QVERIFY_EXCEPTION_THROWN

This change ensures compatibility across all supported Qt versions.

Co-Authored-By: João Barbosa <joao.paulo.barbosa@gmail.com>
This commit is contained in:
Hennadii Stepanov 2024-09-29 14:20:17 +01:00
parent cb750b4b40
commit 5625840c11
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -127,6 +127,11 @@ void RPCNestedTests::rpcNestedTests()
RPCConsole::RPCExecuteCommandLine(m_node, result, "rpcNestedTest( abc , cba )");
QVERIFY(result == "[\"abc\",\"cba\"]");
// Handle deprecated macro, can be removed once minimum Qt is at least 6.3.0.
#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
#undef QVERIFY_EXCEPTION_THROWN
#define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) QVERIFY_THROWS_EXCEPTION(exceptiontype, expression)
#endif
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo() .\n"), std::runtime_error); //invalid syntax
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo() getblockchaininfo()"), std::runtime_error); //invalid syntax
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo("); //tolerate non closing brackets if we have no arguments