summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-08-08 15:39:56 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-08-09 12:13:26 -0700
commit395c9ac731e3789f336bad09cb4a8918a73be43d (patch)
tree50fd67c59f451a75b898bcf74d953672fbf1e300 /tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
parentc49bf9fe27e0632aa8da393ff007cf4577a1c9cd (diff)
Tests: remove #define COMMA
Those were workarounds to passing a comma to a macro, but there are ways around it. The simplest is to just use variadic macros; another, which has been applied to Q_DECLARE_METATYPE for a long time, is to define an alias to the thing you're trying to use. Change-Id: Ie4bb662dcb274440ab8bfffd17097fbf0c53eabc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp')
-rw-r--r--tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
index a3b31eda3f..9ada7352b4 100644
--- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
+++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp
@@ -14,7 +14,6 @@
# define HAVE_FALLBACK_ENGINE
#endif
-#define COMMA ,
#define QVERIFY_3TIMES(statement) \
do {\
if (!static_cast<bool>(statement))\
@@ -165,8 +164,8 @@ QT_WARNING_POP
QRandomGenerator64 systemRng64 = *system64;
systemRng64 = *system64;
- static_assert(std::is_same<decltype(rng64.generate()) COMMA quint64>::value);
- static_assert(std::is_same<decltype(system64->generate()) COMMA quint64>::value);
+ static_assert(std::is_same_v<decltype(rng64.generate()), quint64>);
+ static_assert(std::is_same_v<decltype(system64->generate()), quint64>);
}
void tst_QRandomGenerator::knownSequence()
@@ -895,18 +894,20 @@ void tst_QRandomGenerator::stdGenerateCanonical()
{
QFETCH(uint, control);
RandomGenerator rng(control);
+ auto generate_canonical = [&rng]() {
+ return std::generate_canonical<qreal, 32>(rng);
+ };
for (int i = 0; i < 4; ++i) {
QVERIFY_3TIMES([&] {
- qreal value = std::generate_canonical<qreal COMMA 32>(rng);
+ qreal value = generate_canonical();
return value > 0 && value < 1 && value != RandomValueFP;
}());
}
// and should hopefully be different from repeated calls
for (int i = 0; i < 4; ++i)
- QVERIFY_3TIMES(std::generate_canonical<qreal COMMA 32>(rng) !=
- std::generate_canonical<qreal COMMA 32>(rng));
+ QVERIFY_3TIMES(generate_canonical() != generate_canonical());
}
void tst_QRandomGenerator::stdUniformRealDistribution_data()