diff --git a/src/3rdparty/tinycbor/tests/encoder/data.cpp b/src/3rdparty/tinycbor/tests/encoder/data.cpp index 2c902d85eef..dc7c6a91a1a 100644 --- a/src/3rdparty/tinycbor/tests/encoder/data.cpp +++ b/src/3rdparty/tinycbor/tests/encoder/data.cpp @@ -24,7 +24,29 @@ #include -static float myNaNf() +struct NegativeInteger { quint64 abs; }; +Q_DECLARE_METATYPE(NegativeInteger) + +struct SimpleType { uint8_t type; }; +Q_DECLARE_METATYPE(SimpleType) + +struct Float16Standin { uint16_t val; }; +Q_DECLARE_METATYPE(Float16Standin) + +struct Tag { CborTag tag; QVariant tagged; }; +Q_DECLARE_METATYPE(Tag) + +typedef QVector> Map; +Q_DECLARE_METATYPE(Map) + +struct IndeterminateLengthArray : QVariantList { using QVariantList::QVariantList; }; +struct IndeterminateLengthMap : Map { using Map::Map; }; +Q_DECLARE_METATYPE(IndeterminateLengthArray) +Q_DECLARE_METATYPE(IndeterminateLengthMap) + +namespace { + +float myNaNf() { uint32_t v = 0x7fc00000; float f; @@ -33,7 +55,7 @@ static float myNaNf() return f; } -static float myInff() +float myInff() { uint32_t v = 0x7f800000; float f; @@ -42,7 +64,7 @@ static float myInff() return f; } -static float myNInff() +float myNInff() { uint32_t v = 0xff800000; float f; @@ -51,7 +73,7 @@ static float myNInff() return f; } -static double myNaN() +double myNaN() { uint64_t v = UINT64_C(0x7ff8000000000000); double f; @@ -60,7 +82,7 @@ static double myNaN() return f; } -static double myInf() +double myInf() { uint64_t v = UINT64_C(0x7ff0000000000000); double f; @@ -69,7 +91,7 @@ static double myInf() return f; } -static double myNInf() +double myNInf() { uint64_t v = UINT64_C(0xfff0000000000000); double f; @@ -83,36 +105,17 @@ template QByteArray raw(const char (&data)[N]) return QByteArray::fromRawData(data, N - 1); } -struct NegativeInteger { quint64 abs; }; -Q_DECLARE_METATYPE(NegativeInteger) - -struct SimpleType { uint8_t type; }; -Q_DECLARE_METATYPE(SimpleType) - -struct Float16Standin { uint16_t val; }; -Q_DECLARE_METATYPE(Float16Standin) - -struct Tag { CborTag tag; QVariant tagged; }; -Q_DECLARE_METATYPE(Tag) - template QVariant make_list(const Args &... args) { return QVariantList{args...}; } -typedef QVector> Map; -Q_DECLARE_METATYPE(Map) QVariant make_map(const std::initializer_list> &list) { return QVariant::fromValue(Map(list)); } -struct IndeterminateLengthArray : QVariantList { using QVariantList::QVariantList; }; -struct IndeterminateLengthMap : Map { using Map::Map; }; -Q_DECLARE_METATYPE(IndeterminateLengthArray) -Q_DECLARE_METATYPE(IndeterminateLengthMap) - QVariant make_ilarray(const std::initializer_list &list) { return QVariant::fromValue(IndeterminateLengthArray(list)); @@ -343,4 +346,4 @@ void addArraysAndMaps() QTest::newRow("array-1(map)") << raw("\x81\xc1\xa0") << make_list(QVariant::fromValue(Tag{1, make_map({})})); QTest::newRow("map-1(2):3(4)") << raw("\xa1\xc1\2\xc3\4") << make_map({{QVariant::fromValue(Tag{1, 2}), QVariant::fromValue(Tag{3, 4})}}); } - +} // namespace diff --git a/src/3rdparty/tinycbor/tests/parser/data.cpp b/src/3rdparty/tinycbor/tests/parser/data.cpp index f701a5a5b0c..c99160ad31f 100644 --- a/src/3rdparty/tinycbor/tests/parser/data.cpp +++ b/src/3rdparty/tinycbor/tests/parser/data.cpp @@ -28,6 +28,8 @@ Q_DECLARE_METATYPE(CborError) +namespace { + template QByteArray raw(const char (&data)[N]) { return QByteArray::fromRawData(data, N - 1); @@ -605,3 +607,4 @@ void addValidationData(size_t minInvalid = ~size_t(0)) // This test technically tests the dumper, not the parser. QTest::newRow("string-utf8-chunk-split") << raw("\x81\x7f\x61\xc2\x61\xa0\xff") << 0 << CborErrorInvalidUtf8TextString; } +} // namespace diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 4c59cf7ee38..2c977c0ddf1 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -34,6 +34,7 @@ if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS) endif() if(WASM) + add_subdirectory(corelib/serialization) add_subdirectory(corelib/text) return() endif() diff --git a/tests/auto/corelib/serialization/CMakeLists.txt b/tests/auto/corelib/serialization/CMakeLists.txt index f728aeb6f7d..ef40e78d249 100644 --- a/tests/auto/corelib/serialization/CMakeLists.txt +++ b/tests/auto/corelib/serialization/CMakeLists.txt @@ -13,6 +13,6 @@ endif() if(TARGET Qt::Network) add_subdirectory(qtextstream) endif() -if(TARGET Qt::Gui AND TARGET Qt::Network AND TARGET Qt::Xml AND NOT INTEGRITY AND NOT QNX) +if(TARGET Qt::Gui AND TARGET Qt::Network AND TARGET Qt::Xml AND NOT INTEGRITY AND NOT QNX AND NOT WASM) add_subdirectory(qxmlstream) endif() diff --git a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp index ac1305057c8..71ea1a9cfde 100644 --- a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp +++ b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp @@ -26,7 +26,6 @@ protected: qint64 readData(char *data, qint64 maxlen) override; qint64 writeData(const char *, qint64) override { return -1; } }; -}; qint64 LargeIODevice::readData(char *data, qint64 maxlen) { @@ -118,3 +117,4 @@ void addValidationHugeDevice(qsizetype byteArrayInvalid, qsizetype stringInvalid addSize("4GB", quint64(1) << 32); addSize("max", std::numeric_limits::max() - sizeof(buf)); } +} // namespace diff --git a/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt b/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt index bab3771b749..29a935977b9 100644 --- a/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt +++ b/tests/auto/corelib/serialization/qcborstreamreader/CMakeLists.txt @@ -16,7 +16,7 @@ qt_internal_add_test(tst_qcborstreamreader tst_qcborstreamreader.cpp INCLUDE_DIRECTORIES ../../../../../src/3rdparty/tinycbor/src - ../../../../../src/3rdparty/tinycbor/tests/parser + ../../../../../src/3rdparty/tinycbor/tests LIBRARIES Qt::CorePrivate ) diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp index afd02dc6b70..96d0f77c327 100644 --- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp +++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp @@ -88,7 +88,7 @@ template<> char *toString(const QCborStreamReader::Type QT_END_NAMESPACE // Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/parser/data.cpp) -#include "data.cpp" +#include "parser/data.cpp" void tst_QCborStreamReader::initTestCase_data() { @@ -927,6 +927,10 @@ void tst_QCborStreamReader::hugeDeviceValidation() QSKIP("This test tries to allocate a huge memory buffer," " which Address Sanitizer flags as a problem"); #endif +#if defined(Q_OS_WASM) + QSKIP("This test tries to allocate a huge memory buffer," + " causes problem on WebAssembly platform which has limited resources."); +#endif // Q_OS_WASM QFETCH(QSharedPointer, device); QFETCH(CborError, expectedError); diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt b/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt index b8721f7ad71..c1a9a87677c 100644 --- a/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt +++ b/tests/auto/corelib/serialization/qcborstreamwriter/CMakeLists.txt @@ -15,5 +15,5 @@ qt_internal_add_test(tst_qcborstreamwriter SOURCES tst_qcborstreamwriter.cpp INCLUDE_DIRECTORIES - ../../../../../src/3rdparty/tinycbor/tests/encoder + ../../../../../src/3rdparty/tinycbor/tests ) diff --git a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp index 898fb785e8a..72a05943206 100644 --- a/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp +++ b/tests/auto/corelib/serialization/qcborstreamwriter/tst_qcborstreamwriter.cpp @@ -29,7 +29,7 @@ private Q_SLOTS: // Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/encoder/data.cpp) typedef quint64 CborTag; -#include "data.cpp" +#include "encoder/data.cpp" void encodeVariant(QCborStreamWriter &writer, const QVariant &v) { diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 4e108672d97..202ecf2a6e6 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -2399,6 +2399,11 @@ void tst_QCborValue::hugeDeviceValidation_data() void tst_QCborValue::hugeDeviceValidation() { +#if defined(Q_OS_WASM) + QSKIP("This test tries to allocate a huge memory buffer," + " causes problem on WebAssembly platform which has limited resources."); +#endif // Q_OS_WASM + QFETCH(QSharedPointer, device); QFETCH(CborError, expectedError); QCborError error = { QCborError::Code(expectedError) }; diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 3c9a83c5aa4..1b2fb299443 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -3895,5 +3895,6 @@ void tst_QDataStream::typedefQt5Compat() } QTEST_MAIN(tst_QDataStream) + #include "tst_qdatastream.moc" diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp index 1b11782bbd7..06d553b0050 100644 --- a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp +++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp @@ -5,7 +5,7 @@ #include #include -class tst_QDataStream : public QObject +class tst_QDataStreamPixmap : public QObject { Q_OBJECT @@ -13,7 +13,7 @@ private slots: void stream_with_pixmap(); }; -void tst_QDataStream::stream_with_pixmap() +void tst_QDataStreamPixmap::stream_with_pixmap() { // This is a QVariantMap with a 3x3 red QPixmap and two strings inside const QByteArray ba = QByteArray::fromBase64( @@ -37,6 +37,6 @@ void tst_QDataStream::stream_with_pixmap() QCOMPARE(map["z"].toString(), QString("there")); } -QTEST_GUILESS_MAIN(tst_QDataStream) +QTEST_GUILESS_MAIN(tst_QDataStreamPixmap) #include "tst_qdatastream_core_pixmap.moc"