Explorar o código

Implement int lists serialization/deserialization

- Implement serialization/deserialization for int/fixed types
- Add and update tests
Alexey Edelev %!s(int64=6) %!d(string=hai) anos
pai
achega
b64d32dd07

+ 116 - 28
src/protobuf/protobufobject.cpp

@@ -29,6 +29,44 @@ using namespace qtprotobuf;
 
 ProtobufObjectPrivate::SerializerRegistry ProtobufObjectPrivate::serializers = {};
 
+namespace {
+    static const char *sint32TypeNameP = "qtprotobuf::sint32";
+    static const char *sint32TypeName = "sint32";
+
+    static const char *sint64TypeNameP = "qtprotobuf::sint64";
+    static const char *sint64TypeName = "sint64";
+
+    static const char *sint32ListTypeNameP = "qtprotobuf::sint32List";
+    static const char *sint32ListTypeName = "sint32List";
+
+    static const char *sint64ListTypeNameP = "qtprotobuf::sint64List";
+    static const char *sint64ListTypeName = "sint64List";
+
+    static const char *fint32TypeNameP = "qtprotobuf::fint32";
+    static const char *fint32TypeName = "fint32";
+
+    static const char *fint64TypeNameP = "qtprotobuf::fint64";
+    static const char *fint64TypeName = "fint64";
+
+    static const char *sfint32TypeNameP = "qtprotobuf::sfint32";
+    static const char *sfint32TypeName = "sfint32";
+
+    static const char *sfint64TypeNameP = "qtprotobuf::sfint64";
+    static const char *sfint64TypeName = "sfint64";
+
+    static const char *fint32ListTypeNameP = "qtprotobuf::fint32List";
+    static const char *fint32ListTypeName = "fint32List";
+
+    static const char *fint64ListTypeNameP = "qtprotobuf::fint64List";
+    static const char *fint64ListTypeName = "fint64List";
+
+    static const char *sfint32ListTypeNameP = "qtprotobuf::sfint32List";
+    static const char *sfint32ListTypeName = "sfint32List";
+
+    static const char *sfint64ListTypeNameP = "qtprotobuf::sfint64List";
+    static const char *sfint64ListTypeName = "sfint64List";
+}
+
 QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue, int fieldIndex, const QLatin1Literal &typeName) const
 {
     qProtoDebug() << __func__ << "propertyValue" << propertyValue << "fieldIndex" << fieldIndex << "typeName" << typeName;
@@ -38,11 +76,11 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
     switch (static_cast<QMetaType::Type>(propertyValue.type())) {
     case QMetaType::Int:
         type = Varint;
-        if (typeName == "qtprotobuf::sint32"
-                || typeName == "sint32") {
+        if (typeName == sint32TypeNameP
+                || typeName == sint32TypeName) {
             result.append(serializeVarintZigZag(propertyValue.toInt()));
-        } else if (typeName == "qtprotobuf::sfint32"
-                   || typeName == "sfint32") {
+        } else if (typeName == sfint32TypeNameP
+                   || typeName == sfint32TypeName) {
             type = Fixed32;
             result.append(serializeFixed(propertyValue.toInt()));
         } else {
@@ -54,11 +92,11 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
         break;
     case QMetaType::LongLong:
         type = Varint;
-        if (typeName == "qtprotobuf::sint64"
-                || typeName == "sint64") {
+        if (typeName == sint64TypeNameP
+                || typeName == sint64TypeName) {
             result.append(serializeVarintZigZag(propertyValue.toLongLong()));
-        } else if (typeName == "qtprotobuf::sfint64"
-                   || typeName == "sfint64") {
+        } else if (typeName == sfint64TypeNameP
+                   || typeName == sfint64TypeName) {
             type = Fixed64;
             result.append(serializeFixed(propertyValue.toLongLong()));
         } else {
@@ -94,11 +132,11 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
         break;
     case QMetaType::User:
         type = LengthDelimited;
-        result.append(serializeUserType(propertyValue, fieldIndex));
+        result.append(serializeUserType(propertyValue, fieldIndex, typeName));
         break;
     case QMetaType::UInt:
-        if (typeName == "qtprotobuf::fint32"
-                || typeName == "fint32") {
+        if (typeName == fint32TypeNameP
+                || typeName == fint32TypeName) {
             type = Fixed32;
             result.append(serializeFixed(propertyValue.toUInt()));
         } else {
@@ -110,8 +148,8 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
         }
         break;
     case QMetaType::ULongLong:
-        if (typeName == "qtprotobuf::fint64"
-                || typeName == "fint64") {
+        if (typeName == fint64TypeNameP
+                || typeName == fint64TypeName) {
             type = Fixed64;
             result.append(serializeFixed(propertyValue.toULongLong()));
         } else {
@@ -139,7 +177,7 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
     return result;
 }
 
-QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValue, int &fieldIndex) const
+QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName) const
 {
     qProtoDebug() << __func__ << "propertyValue" << propertyValue << "fieldIndex" << fieldIndex;
     int userType = propertyValue.userType();
@@ -152,15 +190,51 @@ QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValu
 
     //Check if it's special list
     if (userType == qMetaTypeId<int32List>()) {
+        if (typeName == sint32ListTypeNameP
+                || typeName == sint32ListTypeName) {
+            return serializeListTypeZigZag(propertyValue.value<sint32List>(), fieldIndex);
+        }
+        if (typeName == sfint32ListTypeNameP
+                || typeName == sfint32ListTypeName) {
+            return serializeFixedListType(propertyValue.value<sfint32List>(), fieldIndex);
+        }
         return serializeListType(propertyValue.value<int32List>(), fieldIndex);
     }
 
+    if (userType == qMetaTypeId<uint32List>()) {
+        if (typeName == fint32ListTypeNameP
+                || typeName == fint32ListTypeName) {
+            return serializeFixedListType(propertyValue.value<fint32List>(), fieldIndex);
+        }
+        return serializeListType(propertyValue.value<uint32List>(), fieldIndex);
+    }
+
+    if (userType == qMetaTypeId<int64List>()) {
+        if (typeName == sint64ListTypeNameP
+                || typeName == sint64ListTypeName) {
+            return serializeListTypeZigZag(propertyValue.value<sint64List>(), fieldIndex);
+        }
+        if (typeName == sfint64ListTypeNameP
+                || typeName == sfint64ListTypeName) {
+            return serializeFixedListType(propertyValue.value<sfint64List>(), fieldIndex);
+        }
+        return serializeListType(propertyValue.value<int64List>(), fieldIndex);
+    }
+
+    if (userType == qMetaTypeId<uint64List>()) {
+        if (typeName == fint64ListTypeNameP
+                || typeName == fint64ListTypeName) {
+            return serializeFixedListType(propertyValue.value<fint64List>(), fieldIndex);
+        }
+        return serializeListType(propertyValue.value<uint64List>(), fieldIndex);
+    }
+
     if (userType == qMetaTypeId<FloatList>()) {
-        return serializeListType(propertyValue.value<FloatList>(), fieldIndex);
+        return serializeFixedListType(propertyValue.value<FloatList>(), fieldIndex);
     }
 
     if (userType == qMetaTypeId<DoubleList>()) {
-        return serializeListType(propertyValue.value<DoubleList>(), fieldIndex);
+        return serializeFixedListType(propertyValue.value<DoubleList>(), fieldIndex);
     }
 
     //Otherwise it's user type
@@ -201,8 +275,8 @@ void ProtobufObjectPrivate::deserializeProperty(WireTypes wireType, const QMetaP
     case QMetaType::Int:
         if (wireType == Fixed32) {
             newPropertyValue = deserializeFixed<sfint32>(it);
-        } else if (typeName == "qtprotobuf::sint32"
-                   || typeName == "sint32") {
+        } else if (typeName == sint32TypeNameP
+                   || typeName == sint32TypeName) {
             newPropertyValue = deserializeVarintZigZag<sint32>(it);
         } else {
             newPropertyValue = deserializeVarint<int64>(it);
@@ -211,8 +285,8 @@ void ProtobufObjectPrivate::deserializeProperty(WireTypes wireType, const QMetaP
     case QMetaType::LongLong:
         if (wireType == Fixed64) {
             newPropertyValue = deserializeFixed<sfint64>(it);
-        } else if (typeName == "qtprotobuf::sint64"
-                   || typeName == "sint64") {
+        } else if (typeName == sint64TypeNameP
+                   || typeName == sint64TypeName) {
             newPropertyValue = deserializeVarintZigZag<sint64>(it);
         } else {
             newPropertyValue = deserializeVarint<int64>(it);
@@ -262,25 +336,39 @@ void ProtobufObjectPrivate::deserializeUserType(const QMetaProperty &metaType, Q
     }
 
     if (userType == qMetaTypeId<int32List>()) {
-        if (typeName == "sint32List"
-                || typeName == "qtprotobuf::sint32List") {
+        if (typeName == sint32ListTypeNameP
+                || typeName == sint32ListTypeName) {
             newValue = deserializeVarintListTypeZigZag<int32>(it);
+        } else if (typeName == sfint32ListTypeNameP
+                   || typeName == sfint32ListTypeName) {
+            newValue = deserializeListType<sfint32>(it);
         } else {
             newValue = deserializeVarintListType<int32>(it);
         }
     } else if (userType == qMetaTypeId<int64List>()) {
-        if (typeName == "sint64List"
-                || typeName == "qtprotobuf::sint64List") {
+        if (typeName == sint64ListTypeNameP
+                || typeName == sint64ListTypeName) {
             newValue = deserializeVarintListTypeZigZag<int64>(it);
+        } else if (typeName == sfint64ListTypeNameP
+                   || typeName == sfint64ListTypeName) {
+            newValue = deserializeListType<sfint64>(it);
         } else {
             newValue = deserializeVarintListType<int64>(it);
         }
     } else if (userType == qMetaTypeId<uint32List>()) {
-        //TODO: Check if type is fixed
-        newValue = deserializeVarintListType<uint32>(it);
+        if (typeName == fint32ListTypeNameP
+                           || typeName == fint32ListTypeName) {
+            newValue = deserializeListType<fint32>(it);
+        } else {
+            newValue = deserializeVarintListType<uint32>(it);
+        }
     } else if (userType == qMetaTypeId<uint64List>()) {
-        //TODO: Check if type is fixed
-        newValue = deserializeVarintListType<uint64>(it);
+        if (typeName == fint64ListTypeNameP
+                           || typeName == fint64ListTypeName) {
+            newValue = deserializeListType<fint64>(it);
+        } else {
+            newValue = deserializeVarintListType<uint64>(it);
+        }
     } else if (userType == qMetaTypeId<FloatList>()) {
         newValue = deserializeListType<float>(it);
     } else if (userType == qMetaTypeId<DoubleList>()) {

+ 48 - 4
src/protobuf/protobufobject_p.h

@@ -76,7 +76,7 @@ public:
     inline static bool decodeHeaderByte(unsigned char typeByte, int &fieldIndex, WireTypes &wireType);
 
     QByteArray serializeValue(const QVariant &propertyValue, int fieldIndex, const QLatin1Literal &typeName) const;
-    QByteArray serializeUserType(const QVariant &propertyValue, int &fieldIndex) const;
+    QByteArray serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName) const;
 
     void deserializeProperty(WireTypes wireType, const QMetaProperty &metaProperty, QByteArray::const_iterator &it);
     void deserializeUserType(const QMetaProperty &metaType, QByteArray::const_iterator &it, QVariant &newValue);
@@ -94,7 +94,7 @@ public:
     }
 
     template<typename V,
-             typename std::enable_if_t<std::is_integral<V>::value, int> = 0>
+             typename std::enable_if_t<std::is_signed<V>::value, int> = 0>
     QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) const {
         qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
 
@@ -103,6 +103,25 @@ public:
             return QByteArray();
         }
 
+        QByteArray serializedList;
+        for (auto &value : listValue) {
+            serializedList.append(serializeVarint(value));
+        }
+        //If internal field type is not LengthDelimited, exact amount of fields to be specified
+        serializedList.prepend(serializeVarintZero(static_cast<unsigned int>(serializedList.size())));
+        return serializedList;
+    }
+
+    template<typename V,
+             typename std::enable_if_t<std::is_signed<V>::value, int> = 0>
+    QByteArray serializeListTypeZigZag(const QList<V> &listValue, int &outFieldIndex) const {
+        qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
+
+        if (listValue.count() <= 0) {
+            outFieldIndex = NotUsedFieldIndex;
+            return QByteArray();
+        }
+
         QByteArray serializedList;
         for (auto &value : listValue) {
             serializedList.append(serializeVarintZigZag(value));
@@ -113,7 +132,7 @@ public:
     }
 
     template<typename V,
-             typename std::enable_if_t<std::is_floating_point<V>::value, int> = 0>
+             typename std::enable_if_t<std::is_unsigned<V>::value, int> = 0>
     QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) const {
         qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
 
@@ -122,6 +141,29 @@ public:
             return QByteArray();
         }
 
+        QByteArray serializedList;
+        for (auto &value : listValue) {
+            serializedList.append(serializeVarint(value));
+        }
+        //If internal field type is not LengthDelimited, exact amount of fields to be specified
+        serializedList.prepend(serializeVarintZero(static_cast<unsigned int>(serializedList.size())));
+        return serializedList;
+    }
+
+    template<typename V,
+             typename std::enable_if_t<std::is_floating_point<V>::value
+                                       || std::is_same<V, unsigned int>::value
+                                       || std::is_same<V, qulonglong>::value
+                                       || std::is_same<V, int>::value
+                                       || std::is_same<V, qlonglong>::value, int> = 0>
+    QByteArray serializeFixedListType(const QList<V> &listValue, int &outFieldIndex) const {
+        qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
+
+        if (listValue.count() <= 0) {
+            outFieldIndex = NotUsedFieldIndex;
+            return QByteArray();
+        }
+
         QByteArray serializedList;
         for (auto &value : listValue) {
             serializedList.append(serializeFixed(value));
@@ -348,7 +390,9 @@ public:
     template <typename V,
               typename std::enable_if_t<std::is_floating_point<V>::value
                                         || std::is_same<V, unsigned int>::value
-                                        || std::is_same<V, qulonglong>::value, int> = 0>
+                                        || std::is_same<V, qulonglong>::value
+                                        || std::is_same<V, int>::value
+                                        || std::is_same<V, qlonglong>::value, int> = 0>
     QVariant deserializeListType(QByteArray::const_iterator &it) {
         qProtoDebug() << __func__ << "currentByte:" << QString::number((*it), 16);
 

+ 0 - 1
src/protobuf/qtprotobuf.h

@@ -39,7 +39,6 @@ class QtProtobuf {
 public:
     static void init() {
         static bool registationDone = false;
-        Q_ASSERT_X(!registationDone, "QtProtobuf", "Protobuf registration is already done");
         if (!registationDone) {
             registerProtobufType(int32);
             registerProtobufType(int64);

+ 88 - 2
tests/deserializationtest.cpp

@@ -42,6 +42,15 @@
 #include "repeateddoublemessage.h"
 #include "repeatedfloatmessage.h"
 #include "repeatedintmessage.h"
+#include "repeatedsintmessage.h"
+#include "repeateduintmessage.h"
+#include "repeatedint64message.h"
+#include "repeatedsint64message.h"
+#include "repeateduint64message.h"
+#include "repeatedfixedintmessage.h"
+#include "repeatedsfixedintmessage.h"
+#include "repeatedfixedint64message.h"
+#include "repeatedsfixedint64message.h"
 #include "repeatedcomplexmessage.h"
 
 using namespace qtprotobufnamespace::tests;
@@ -407,9 +416,86 @@ TEST_F(DeserializationTest, RepeatedDoubleMessageTest)
 TEST_F(DeserializationTest, RepeatedIntMessageTest)
 {
     RepeatedIntMessage test;
-    test.deserialize(QByteArray::fromHex("0a0702a00606080a0c"));
+    test.deserialize(QByteArray::fromHex("0a1101c102b1fcfbff0fedc207fdffffff0f03"));
     ASSERT_EQ(6, test.testRepeatedInt().count());
-    ASSERT_TRUE(test.testRepeatedInt() == int32List({1, 400, 3, 4, 5, 6}));
+    ASSERT_TRUE(test.testRepeatedInt() == int32List({1, 321, -65999, 123245, -3, 3}));
+
+    RepeatedIntMessage test2;
+    test2.deserialize(QByteArray::fromHex("0a1b01c102b1fcfbffffffffffff01edc207fdffffffffffffffff0103"));
+    ASSERT_EQ(6, test2.testRepeatedInt().count());
+    ASSERT_TRUE(test2.testRepeatedInt() == int32List({1, 321, -65999, 123245, -3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedSIntMessageTest)
+{
+    RepeatedSIntMessage test;
+    test.deserialize(QByteArray::fromHex("0a0b0282059d8708da850f0506"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == sint32List({1, 321, -65999, 123245, -3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedUIntMessageTest)
+{
+    RepeatedUIntMessage test;
+    test.deserialize(QByteArray::fromHex("0a0a01c102cf8304edc20703"));
+    ASSERT_EQ(5, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == uint32List({1, 321, 65999, 123245, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedInt64MessageTest)
+{
+    RepeatedInt64Message test;
+    test.deserialize(QByteArray::fromHex("0a1f01c102b1fcfbffffffffffff01b3c3cab6d8e602fdffffffffffffffff0103"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == int64List({1, 321, -65999, 12324523123123, -3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedSInt64MessageTest)
+{
+    RepeatedSInt64Message test;
+    test.deserialize(QByteArray::fromHex("0a0f0282059d8708e68695edb0cd050506"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == sint64List({1, 321, -65999, 12324523123123, -3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedUInt64MessageTest)
+{
+    RepeatedUInt64Message test;
+    test.deserialize(QByteArray::fromHex("0a1301c102cf8304edc207d28b9fda82dff6da0103"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == uint64List({1, 321, 65999, 123245, 123245324235425234, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedFixedIntMessageTest)
+{
+    RepeatedFixedIntMessage test;
+    test.deserialize(QByteArray::fromHex("0a180100000041010000cf010100ab0ebc000300000003000000"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == fint32List({1, 321, 65999, 12324523, 3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedSFixedIntMessageTest)
+{
+    RepeatedSFixedIntMessage test;
+    test.deserialize(QByteArray::fromHex("0a18010000004101000031fefeffab0ebc00fdffffff03000000"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == sfint32List({1, 321, -65999, 12324523, -3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedFixedInt64MessageTest)
+{
+    RepeatedFixedInt64Message test;
+    test.deserialize(QByteArray::fromHex("0a3001000000000000004101000000000000cf01010000000000d2c5472bf8dab50103000000000000000300000000000000"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == fint64List({1, 321, 65999, 123245324235425234, 3, 3}));
+}
+
+TEST_F(DeserializationTest, RepeatedSFixedInt64MessageTest)
+{
+    RepeatedSFixedInt64Message test;
+    test.deserialize(QByteArray::fromHex("0a300100000000000000410100000000000031fefeffffffffffd2c5472bf8dab501fdffffffffffffff0300000000000000"));
+    ASSERT_EQ(6, test.testRepeatedInt().count());
+    ASSERT_TRUE(test.testRepeatedInt() == sfint64List({1, 321, -65999, 123245324235425234, -3, 3}));
 }
 
 TEST_F(DeserializationTest, RepeatedComplexMessageTest)

+ 39 - 4
tests/proto/simpletest.proto

@@ -95,10 +95,6 @@ message ComplexMessage {
     SimpleStringMessage testComplexField = 2;
 }
 
-message RepeatedIntMessage {
-    repeated sint32 testRepeatedInt = 1;
-}
-
 message RepeatedStringMessage {
     repeated string testRepeatedString = 1;
 }
@@ -123,6 +119,45 @@ message RepeatedExternalComplexMessage {
     repeated qtprotobufnamespace1.externaltests.ExternalComplexMessage testExternalComplex = 1;
 }
 
+message RepeatedSIntMessage {
+    repeated sint32 testRepeatedInt = 1;
+}
+
+message RepeatedIntMessage {
+    repeated int32 testRepeatedInt = 1;
+}
+
+message RepeatedUIntMessage {
+    repeated uint32 testRepeatedInt = 1;
+}
+
+message RepeatedSInt64Message {
+    repeated sint64 testRepeatedInt = 1;
+}
+
+message RepeatedInt64Message {
+    repeated int64 testRepeatedInt = 1;
+}
+
+message RepeatedUInt64Message {
+    repeated uint64 testRepeatedInt = 1;
+}
+
+message RepeatedFixedIntMessage {
+    repeated fixed32 testRepeatedInt = 1;
+}
+
+message RepeatedSFixedIntMessage {
+    repeated sfixed32 testRepeatedInt = 1;
+}
+
+message RepeatedFixedInt64Message {
+    repeated fixed64 testRepeatedInt = 1;
+}
+
+message RepeatedSFixedInt64Message {
+    repeated sfixed64 testRepeatedInt = 1;
+}
 
 enum TestEnum {
     TEST_ENUM_VALUE0 = 0;

+ 128 - 3
tests/serializationtest.cpp

@@ -40,6 +40,15 @@
 #include "simplestringmessage.h"
 #include "complexmessage.h"
 #include "repeatedintmessage.h"
+#include "repeatedsintmessage.h"
+#include "repeateduintmessage.h"
+#include "repeatedint64message.h"
+#include "repeatedsint64message.h"
+#include "repeateduint64message.h"
+#include "repeatedfixedintmessage.h"
+#include "repeatedsfixedintmessage.h"
+#include "repeatedfixedint64message.h"
+#include "repeatedsfixedint64message.h"
 #include "repeatedstringmessage.h"
 #include "repeateddoublemessage.h"
 #include "repeatedbytesmessage.h"
@@ -1395,12 +1404,128 @@ TEST_F(SerializationTest, ComplexTypeSerializeTest)
 TEST_F(SerializationTest, RepeatedIntMessageTest)
 {
     RepeatedIntMessage test;
-    test.setTestRepeatedInt({1, 400, 3, 4, 5, 6});
+    test.setTestRepeatedInt({1, 321, -65999, 123245, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "RepeatedIntMessage result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a1101c102b1fcfbff0fedc207fdffffff0f03"));
+    test.setTestRepeatedInt(int32List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedSIntMessageTest)
+{
+    RepeatedSIntMessage test;
+    test.setTestRepeatedInt({1, 321, -65999, 123245, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "RepeatedSIntMessage result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a0b0282059d8708da850f0506"));
+
+    test.setTestRepeatedInt(sint32List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedUIntMessageTest)
+{
+    RepeatedUIntMessage test;
+    test.setTestRepeatedInt({1, 321, 65999, 123245, 3});
     QByteArray result = test.serialize();
     //qDebug() << "result " << result.toHex();
-    ASSERT_TRUE(result == QByteArray::fromHex("0a0702a00606080a0c"));
+    ASSERT_TRUE(result == QByteArray::fromHex("0a0a01c102cf8304edc20703"));
 
-    test.setTestRepeatedInt(int32List());
+    test.setTestRepeatedInt(uint32List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedInt64MessageTest)
+{
+    RepeatedInt64Message test;
+    test.setTestRepeatedInt({1, 321, -65999, 12324523123123, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a1f01c102b1fcfbffffffffffff01b3c3cab6d8e602fdffffffffffffffff0103"));
+
+    test.setTestRepeatedInt(int64List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedSInt64MessageTest)
+{
+    RepeatedSInt64Message test;
+    test.setTestRepeatedInt({1, 321, -65999, 12324523123123, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a0f0282059d8708e68695edb0cd050506"));
+
+    test.setTestRepeatedInt(sint64List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedUInt64MessageTest)
+{
+    RepeatedUInt64Message test;
+    test.setTestRepeatedInt({1, 321, 65999, 123245, 123245324235425234, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a1301c102cf8304edc207d28b9fda82dff6da0103"));
+
+    test.setTestRepeatedInt(uint64List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedFixedIntMessageTest)
+{
+    RepeatedFixedIntMessage test;
+    test.setTestRepeatedInt({1, 321, 65999, 12324523, 3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a180100000041010000cf010100ab0ebc000300000003000000"));
+
+    test.setTestRepeatedInt(fint32List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedSFixedIntMessageTest)
+{
+    RepeatedSFixedIntMessage test;
+    test.setTestRepeatedInt({1, 321, -65999, 12324523, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a18010000004101000031fefeffab0ebc00fdffffff03000000"));
+
+    test.setTestRepeatedInt(sfint32List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedFixedInt64MessageTest)
+{
+    RepeatedFixedInt64Message test;
+    test.setTestRepeatedInt({1, 321, 65999, 123245324235425234, 3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a3001000000000000004101000000000000cf01010000000000d2c5472bf8dab50103000000000000000300000000000000"));
+
+    test.setTestRepeatedInt(fint64List());
+    result = test.serialize();
+    ASSERT_TRUE(result.isEmpty());
+}
+
+TEST_F(SerializationTest, RepeatedSFixedInt64MessageTest)
+{
+    RepeatedSFixedInt64Message test;
+    test.setTestRepeatedInt({1, 321, -65999, 123245324235425234, -3, 3});
+    QByteArray result = test.serialize();
+    //qDebug() << "result " << result.toHex();
+    ASSERT_TRUE(result == QByteArray::fromHex("0a300100000000000000410100000000000031fefeffffffffffd2c5472bf8dab501fdffffffffffffff0300000000000000"));
+
+    test.setTestRepeatedInt(sfint64List());
     result = test.serialize();
     ASSERT_TRUE(result.isEmpty());
 }

+ 128 - 2
tests/simpletest.cpp

@@ -46,6 +46,15 @@
 #include "complexmessage.h"
 #include "simplebytesmessage.h"
 #include "repeatedintmessage.h"
+#include "repeatedsintmessage.h"
+#include "repeateduintmessage.h"
+#include "repeatedint64message.h"
+#include "repeatedsint64message.h"
+#include "repeateduint64message.h"
+#include "repeatedfixedintmessage.h"
+#include "repeatedsfixedintmessage.h"
+#include "repeatedfixedint64message.h"
+#include "repeatedsfixedint64message.h"
 #include "globalenums.h"
 #include "qtprotobuf.h"
 #include <QVariantList>
@@ -356,14 +365,131 @@ TEST_F(SimpleTest, RepeatedIntMessageTest)
     const char* propertyName = "testRepeatedInt";
     RepeatedIntMessage test;
     int propertyNumber = RepeatedIntMessage::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_STREQ(RepeatedIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sint32List");
-    ASSERT_EQ(RepeatedIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::sint32List>());
+    ASSERT_STREQ(RepeatedIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::int32List");
+    ASSERT_EQ(RepeatedIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::int32List>());
     ASSERT_STREQ(RepeatedIntMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<int32List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<int32List>() == int32List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == int32List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedSIntMessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedSIntMessage test;
+    int propertyNumber = RepeatedSIntMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedSIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sint32List");
+    ASSERT_EQ(RepeatedSIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::sint32List>());
+    ASSERT_STREQ(RepeatedSIntMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
     ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sint32List>({1, 2, 3, 4, 5})));
     ASSERT_TRUE(test.property(propertyName).value<sint32List>() == sint32List({1, 2, 3, 4, 5}));
     ASSERT_TRUE(test.testRepeatedInt() == sint32List({1, 2, 3, 4, 5}));
 }
 
+TEST_F(SimpleTest, RepeatedUIntMessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedUIntMessage test;
+    int propertyNumber = RepeatedUIntMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedUIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::uint32List");
+    ASSERT_EQ(RepeatedUIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::uint32List>());
+    ASSERT_STREQ(RepeatedUIntMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<uint32List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<uint32List>() == uint32List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == uint32List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedInt64MessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedInt64Message test;
+    int propertyNumber = RepeatedInt64Message::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::int64List");
+    ASSERT_EQ(RepeatedInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::int64List>());
+    ASSERT_STREQ(RepeatedInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<int64List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<int64List>() == int64List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == int64List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedSInt64MessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedSInt64Message test;
+    int propertyNumber = RepeatedSInt64Message::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedSInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sint64List");
+    ASSERT_EQ(RepeatedSInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::sint64List>());
+    ASSERT_STREQ(RepeatedSInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sint64List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<sint64List>() == sint64List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == sint64List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedUInt64MessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedUInt64Message test;
+    int propertyNumber = RepeatedUInt64Message::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedUInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::uint64List");
+    ASSERT_EQ(RepeatedUInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::uint64List>());
+    ASSERT_STREQ(RepeatedUInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<uint64List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<uint64List>() == uint64List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == uint64List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedFixedIntMessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedFixedIntMessage test;
+    int propertyNumber = RepeatedFixedIntMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedFixedIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::fint32List");
+    ASSERT_EQ(RepeatedFixedIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::fint32List>());
+    ASSERT_STREQ(RepeatedFixedIntMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<fint32List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<fint32List>() == fint32List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == fint32List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedFixedInt64MessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedFixedInt64Message test;
+    int propertyNumber = RepeatedFixedInt64Message::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedFixedInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::fint64List");
+    ASSERT_EQ(RepeatedFixedInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::fint64List>());
+    ASSERT_STREQ(RepeatedFixedInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<fint64List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<fint64List>() == fint64List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == fint64List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedSFixedIntMessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedSFixedIntMessage test;
+    int propertyNumber = RepeatedSFixedIntMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedSFixedIntMessage::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sfint32List");
+    ASSERT_EQ(RepeatedSFixedIntMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::sfint32List>());
+    ASSERT_STREQ(RepeatedSFixedIntMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sfint32List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<sfint32List>() == sfint32List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == sfint32List({1, 2, 3, 4, 5}));
+}
+
+TEST_F(SimpleTest, RepeatedSFixedInt64MessageTest)
+{
+    const char* propertyName = "testRepeatedInt";
+    RepeatedSFixedInt64Message test;
+    int propertyNumber = RepeatedSFixedInt64Message::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(RepeatedSFixedInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sfint64List");
+    ASSERT_EQ(RepeatedSFixedInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<qtprotobuf::sfint64List>());
+    ASSERT_STREQ(RepeatedSFixedInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sfint64List>({1, 2, 3, 4, 5})));
+    ASSERT_TRUE(test.property(propertyName).value<sfint64List>() == sfint64List({1, 2, 3, 4, 5}));
+    ASSERT_TRUE(test.testRepeatedInt() == sfint64List({1, 2, 3, 4, 5}));
+}
+
 TEST_F(SimpleTest, StepChildEnumMessageTest)
 {
     const char* propertyName = "localStepChildEnum";