diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-16 20:13:28 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-17 09:44:03 +0100 |
commit | 3dc1339dba5c42d3891285a0a9f4b8d4b3195ce6 (patch) | |
tree | 167b015f58f8e69d913d4177abd98fa205ed5e85 /tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | |
parent | a2209698d3584a7c05d0c12aa61de050fe0e78fd (diff) |
QV4Engine: Fix conversion of char16_t
This is a single char16_t, not an array of them.
Pick-to: 5.15
Change-Id: I55d23ebb5f2abebd43cd4160a75d373706392ddf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp')
-rw-r--r-- | tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 2829ab08a1..cf6ed273af 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -99,6 +99,7 @@ private slots: void enumProperties(); void scarceTypes(); void nonValueTypes(); + void char16Type(); private: QQmlEngine engine; @@ -1843,7 +1844,22 @@ void tst_qqmlvaluetypes::scarceTypes() void tst_qqmlvaluetypes::nonValueTypes() { CHECK_TYPE_IS_NOT_VALUETYPE(UnknownType, 0, void) - QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(CHECK_TYPE_IS_NOT_VALUETYPE); + QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(CHECK_TYPE_IS_NOT_VALUETYPE); +} + +void tst_qqmlvaluetypes::char16Type() +{ + QV4::ExecutionEngine engine; + QV4::Scope scope(&engine); + + char16_t t = 't'; + QVariant v = QVariant::fromValue(t); + char16_t *vt = static_cast<char16_t *>(v.data()); + *vt++ = 'a'; + *vt++ = 'u'; + QCOMPARE(v.typeId(), QMetaType::Char16); + QV4::ScopedValue scoped(scope, engine.fromVariant(v)); + QCOMPARE(scoped->toQString(), "a"); } #undef CHECK_TYPE_IS_NOT_VALUETYPE |