From 3d1b9b09e7651c2062111d5a624568f3d18ac1fa Mon Sep 17 00:00:00 2001 From: George Nash Date: Tue, 7 Feb 2017 15:30:30 -0800 Subject: [PATCH] Fix for missing-field-initializers compiler warning 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/17101 Tested-by: jenkins-iotivity Reviewed-by: Larry Sachs Reviewed-by: Rick Bell --- resource/unittests/OCRepresentationTest.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/resource/unittests/OCRepresentationTest.cpp b/resource/unittests/OCRepresentationTest.cpp index bf41e98..b0fc992 100644 --- a/resource/unittests/OCRepresentationTest.cpp +++ b/resource/unittests/OCRepresentationTest.cpp @@ -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)); -- 2.7.4