Obsolete Members for QTest
类QTest 的以下成员已被弃用。提供这些成员是为了保持旧源代码的正常运行。我们强烈建议不要在新代码中使用它们。
函数
(deprecated in 6.4) bool | compare_helper(bool success, const char *failureMsg, char *actualVal, char *expectedVal, const char *actual, const char *expected, const char *file, int line) |
(deprecated in 6.3) void | qWarn(const char *message, const char *file = nullptr, int line = 0) |
宏
(deprecated in 6.3) | QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) |
(deprecated) | QWARN(message) |
函数文档
[deprecated in 6.4] bool QTest::compare_helper(bool success, const char *failureMsg, char *actualVal, char *expectedVal, const char *actual, const char *expected, const char *file, int line)
自 6.4 版起,该函数已被弃用。我们强烈建议不要在新代码中使用它。
QTest::qCompare 的各种特殊化都会调用此函数,以决定是否报告失败并生成冗长的测试输出。
failureMsg 参数可以为空,在这种情况下,如果比较失败,将输出默认信息。如果比较成功,则不会输出 failureMsg。
使用此函数并非最佳选择,因为它需要预先计算actualVal 和expectedVal 的字符串表示,尽管只有在比较失败时才会使用它们。在这种情况下,最好使用使用 qxp::function_ref() 的 compare_helper()重载。
如果调用者创建了显示比较值的自定义失败消息,或者这些值无法被字符串化,则使用不带actualVal 和expectedVal 参数的函数重载。
[deprecated in 6.3] void QTest::qWarn(const char *message, const char *file = nullptr, int line = 0)
自 6.3 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
请使用qWarning() 代替它。
宏文档
[deprecated in 6.3] QVERIFY_EXCEPTION_THROWN(expression, exceptiontype)
自 6.3 版起,该宏已被弃用。我们强烈建议不要在新代码中使用它。
请使用QVERIFY_THROWS_EXCEPTION(exceptiontype, expression) 。
[deprecated] QWARN(message)
该宏已被弃用。我们强烈建议不要在新代码中使用它。
请使用qWarning() 代替。
将message 作为警告添加到测试日志中。此宏可在测试的任何地方使用。
注意:此宏是线程安全的。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.