From d8d39ce04b8c1cd316cace3a65df71b2484e058f Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Sun, 10 Dec 2023 10:21:41 +0100 Subject: [PATCH] Fix enum serialization test Test functions were not slots and never run. Also ajust the QCOMPARE statements. Change-Id: I0c6740e1a4a37f02d3460bed6254844e62268fe7 Reviewed-by: Tatiana Borisova (cherry picked from commit e6bc1582960f10f48d6d166d3c15154b45b56b0b) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit acf3d35287185801eb381167234b26cb4689d59d) --- .../enums/tst_protobuf_serialization_enumtypes.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/auto/protobuf/enums/tst_protobuf_serialization_enumtypes.cpp b/tests/auto/protobuf/enums/tst_protobuf_serialization_enumtypes.cpp index d34c2dae..e5ed4779 100644 --- a/tests/auto/protobuf/enums/tst_protobuf_serialization_enumtypes.cpp +++ b/tests/auto/protobuf/enums/tst_protobuf_serialization_enumtypes.cpp @@ -10,11 +10,10 @@ class QtProtobufEnumTypesSerializationTest : public QObject { Q_OBJECT -public: +private slots: void SimpleEnumMessageSerializeTest(); void RepeatedEnumMessageTest(); -private slots: void init() { m_serializer.reset(new QProtobufSerializer); } @@ -23,6 +22,7 @@ private: }; using namespace qtprotobufnamespace::tests; +using namespace Qt::Literals::StringLiterals; void QtProtobufEnumTypesSerializationTest::SimpleEnumMessageSerializeTest() { @@ -30,7 +30,7 @@ void QtProtobufEnumTypesSerializationTest::SimpleEnumMessageSerializeTest() test.setLocalEnum(SimpleEnumMessage::LOCAL_ENUM_VALUE2); QByteArray result = test.serialize(m_serializer.get()); QCOMPARE(result.size(), 2); - QCOMPARE(result.toHex().toStdString().c_str(), "0802"); + QCOMPARE(result.toHex(), "0802"_ba); } void QtProtobufEnumTypesSerializationTest::RepeatedEnumMessageTest() @@ -44,12 +44,10 @@ void QtProtobufEnumTypesSerializationTest::RepeatedEnumMessageTest() RepeatedEnumMessage::LOCAL_ENUM_VALUE2, RepeatedEnumMessage::LOCAL_ENUM_VALUE3}); QByteArray result = msg.serialize(m_serializer.get()); - QCOMPARE(result.toHex().toStdString().c_str(), - "0a06000102010203"); + QCOMPARE(result.toHex(), "0a06000102010203"_ba); msg.setLocalEnumList({}); result = msg.serialize(m_serializer.get()); - QCOMPARE(result.toHex().toStdString().c_str(), - ""); + QCOMPARE(result.toHex(), ""_ba); } QTEST_MAIN(QtProtobufEnumTypesSerializationTest)