diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-04 15:15:26 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-09 04:05:50 -0700 |
commit | 393d5efda30aac8f20c35dc22b7d22c350f6f096 (patch) | |
tree | b82007f3b82deeece3475ef597495bd226efe69e /src/testlib/qtest.h | |
parent | 250ca8d5f8bb3771695ae8eccb8d9b469003d840 (diff) |
QVariant: make a major simplification in the numeric comparison
The code implementing the C++ rules of type promotion and conversion
was too pedantic. There's no need to follow the letter of the standard,
not when we can now assume that everything is two's complement (this was
true for all architectures we supported when I wrote this code in 2014,
but wasn't required by the standard).
So we can reduce this to fewer comparisons and fewer rules, using the
size of the type, not just the type ID.
Change-Id: I3d74c753055744deb8acfffd172446b02444c0c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/testlib/qtest.h')
-rw-r--r-- | src/testlib/qtest.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 7b845a61a9..f87995e0db 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -207,6 +207,19 @@ template<> inline char *toString(const QVariant &v) return qstrdup(vstring.constData()); } +template<> inline char *toString(const QPartialOrdering &o) +{ + if (o == QPartialOrdering::Less) + return qstrdup("Less"); + if (o == QPartialOrdering::Equivalent) + return qstrdup("Equivalent"); + if (o == QPartialOrdering::Greater) + return qstrdup("Greater"); + if (o == QPartialOrdering::Unordered) + return qstrdup("Unordered"); + return qstrdup("<invalid>"); +} + namespace Internal { struct QCborValueFormatter { |