Make test code use the correct signed types
There were a number of comparisons in the tests that were comparing
signed ints to unsigned ints. This lead to compiler errors in some
cases.
../../../../../../workspace/sources/phosphor-snmp/test/test_error_notification.cpp:35:5:
required from here
| /usr/src/gtest/include/gtest/gtest.h:1545:11:
error: comparison of integer expressions of different signedness: 'const
int' and 'const unsigned int' [-Werror=sign-compare]
| if (lhs == rhs) {
This commit fixes it.
Tested: Code compiles, unit test changes only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib6dd2afced3672ec1f7096ade07b36d53049cf1a
diff --git a/test/test_error_notification.cpp b/test/test_error_notification.cpp
index 71a554a..270932f 100644
--- a/test/test_error_notification.cpp
+++ b/test/test_error_notification.cpp
@@ -11,7 +11,7 @@
namespace snmp
{
-constexpr auto ERROR_NOTIF_FIELD_COUNT = 4;
+constexpr size_t ERROR_NOTIF_FIELD_COUNT = 4;
class TestErrorNotification : public testing::Test
{
diff --git a/test/test_snmp_conf_manager.cpp b/test/test_snmp_conf_manager.cpp
index de89272..13739b5 100644
--- a/test/test_snmp_conf_manager.cpp
+++ b/test/test_snmp_conf_manager.cpp
@@ -85,7 +85,7 @@
// check whether the client created
auto& clients = getSNMPClients();
- EXPECT_EQ(1, clients.size());
+ EXPECT_EQ(1U, clients.size());
EXPECT_EQ(true, isClientExist("192.168.1.1"));
}
@@ -103,7 +103,7 @@
// check both the clients get created
auto& clients = getSNMPClients();
- EXPECT_EQ(2, clients.size());
+ EXPECT_EQ(2U, clients.size());
EXPECT_EQ(true, isClientExist("192.168.1.1"));
EXPECT_EQ(true, isClientExist("192.168.1.2"));
@@ -123,7 +123,7 @@
createSNMPClient("192.168.1.2", 24);
auto& clients = getSNMPClients();
- EXPECT_EQ(2, clients.size());
+ EXPECT_EQ(2U, clients.size());
deleteSNMPClient("192.168.1.1");
@@ -132,7 +132,7 @@
expectedPath += std::string("/3");
EXPECT_EQ(path, expectedPath);
- EXPECT_EQ(2, clients.size());
+ EXPECT_EQ(2U, clients.size());
EXPECT_EQ(true, isClientExist("192.168.1.2"));
EXPECT_EQ(false, isClientExist("192.168.1.1"));
EXPECT_EQ(true, isClientExist("192.168.1.3"));