Fix for missing-field-initializers compiler warning
authorGeorge Nash <george.nash@intel.com>
Tue, 7 Feb 2017 23:30:30 +0000 (15:30 -0800)
committerRick Bell <richard.s.bell@intel.com>
Thu, 9 Feb 2017 19:22:16 +0000 (19:22 +0000)
The OCDevAddr struct has 7 values only 2 were
initilized when the addr struct was created.

Two values the port and addr were set after the
initilization. All values are now intilized when
the OCDevAddr struct is created.

In addition the EXPECT_EQ was changed to EXPECT_STREQ
the macro undertands that a string is expected and
will display more informative errors if the test fails.

Change-Id: I74093d0a42961f65c3709254e949b8feb8aec587
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17101
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
resource/unittests/OCRepresentationTest.cpp

index bf41e98..b0fc992 100644 (file)
@@ -1450,22 +1450,17 @@ namespace OCRepresentationTest
 
     TEST(OCRepresentationHostTest, ValidHost)
     {
-        OCDevAddr addr = {OC_DEFAULT_ADAPTER, OC_IP_USE_V6};
-        addr.port = 5000;
-        strcpy(addr.addr, "fe80::1%eth0");
+        OCDevAddr addr = {OC_DEFAULT_ADAPTER, OC_IP_USE_V6, 5000, "fe80::1%eth0", 0, "", ""};
 
         OCRepresentation rep;
         rep.setDevAddr(addr);
         std::string host = rep.getHost();
-        std::string expected = "coap://[fe80::1%25eth0]:5000";
-        EXPECT_EQ(host, expected);
+        EXPECT_STREQ("coap://[fe80::1%25eth0]:5000", host.c_str());
     }
 
     TEST(OCRepresentationHostTest, InvalidHost)
     {
-        OCDevAddr addr = {OC_DEFAULT_ADAPTER, OC_IP_USE_V6};
-        addr.port = 5000;
-        strcpy(addr.addr, "fe80::1%%");
+        OCDevAddr addr = {OC_DEFAULT_ADAPTER, OC_IP_USE_V6, 5000, "fe80::1%%", 0, "", ""};
 
         OCRepresentation rep;
         EXPECT_ANY_THROW(rep.setDevAddr(addr));