Browse Source

Fix tests

- Make tests for complex message order independend
- Move field header generation function to common parent class
Alexey Edelev 6 years ago
parent
commit
fc01627453
2 changed files with 12 additions and 11 deletions
  1. 10 10
      src/lib/protobufobject.h
  2. 2 1
      tests/serializationtest.cpp

+ 10 - 10
src/lib/protobufobject.h

@@ -50,6 +50,16 @@ class ProtobufObjectPrivate : public QObject {
 protected:
     explicit ProtobufObjectPrivate(QObject *parent = nullptr) : QObject(parent) {}
 
+    inline static unsigned char getTypeByte(int fieldIndex, WireTypes wireType) {
+        /*  Header byte
+         *  bits    | 7  6  5  4  3 |  2  1  0
+         *  -----------------------------------
+         *  meaning |  Field index  |   Type
+         */
+        unsigned char header = (fieldIndex << 3) | wireType;
+        return *(char *)&header;
+    }
+
 public:
     virtual QByteArray serializePrivate() = 0;
 };
@@ -178,16 +188,6 @@ public:
         result.data()[result.size() - 1] &= ~0x80;
         return result;
     }
-
-    inline unsigned char getTypeByte(int fieldIndex, WireTypes wireType) {
-        /*  Header byte
-         *  bits    | 7  6  5  4  3 |  2  1  0
-         *  -----------------------------------
-         *  meaning |  Field index  |   Type
-         */
-        unsigned char header = (fieldIndex << 3) | wireType;
-        return *(char *)&header;
-    }
 };
 
 }

File diff suppressed because it is too large
+ 2 - 1
tests/serializationtest.cpp


Some files were not shown because too many files changed in this diff