Browse Source

Implement tests for bool type

Alexey Edelev 6 years ago
parent
commit
e5d63ed8b7
2 changed files with 18 additions and 0 deletions
  1. 4 0
      tests/proto/simpletest.proto
  2. 14 0
      tests/simpletest.cpp

+ 4 - 0
tests/proto/simpletest.proto

@@ -19,6 +19,10 @@ message SimpleFileEnumMessage {
   repeated TestEnum globalEnumList = 2;
 }
 
+message SimpleBoolMessage {
+    bool testFieldBool = 1;
+}
+
 message SimpleIntMessage {
     int32 testFieldInt = 1;
 }

+ 14 - 0
tests/simpletest.cpp

@@ -25,6 +25,7 @@
 
 #include "simpletest.h"
 
+#include "simpleboolmessage.h"
 #include "simpleintmessage.h"
 #include "simplesintmessage.h"
 #include "simpleuintmessage.h"
@@ -57,6 +58,19 @@ SimpleTest::SimpleTest()
     QtProtobuf::init();
 }
 
+TEST_F(SimpleTest, SimpleBoolMessageTest)
+{
+    const char* propertyName = "testFieldBool";
+    SimpleBoolMessage test;
+    int propertyNumber = SimpleBoolMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(SimpleBoolMessage::staticMetaObject.property(propertyNumber).typeName(), "bool");
+    ASSERT_EQ(SimpleBoolMessage::staticMetaObject.property(propertyNumber).type(), qMetaTypeId<bool>());
+    ASSERT_STREQ(SimpleBoolMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue(true)));
+    ASSERT_EQ(test.property(propertyName).toBool(), true);
+    ASSERT_EQ(test.testFieldBool(), true);
+}
+
 TEST_F(SimpleTest, SimpleIntMessageTest)
 {
     const char* propertyName = "testFieldInt";