Ratan Gupta | ec26fa6 | 2018-04-16 15:28:36 +0530 | [diff] [blame] | 1 | #include "snmp_notification.hpp" |
| 2 | #include <gtest/gtest.h> |
| 3 | #include <netinet/in.h> |
| 4 | |
| 5 | namespace phosphor |
| 6 | { |
| 7 | namespace network |
| 8 | { |
| 9 | namespace snmp |
| 10 | { |
| 11 | |
| 12 | constexpr auto ERROR_NOTIF_FIELD_COUNT = 4; |
| 13 | |
| 14 | class TestErrorNotification : public testing::Test |
| 15 | { |
| 16 | public: |
| 17 | OBMCErrorNotification notif; |
| 18 | TestErrorNotification() |
| 19 | { |
| 20 | // Empty |
| 21 | } |
| 22 | std::vector<Object> getFieldOIDList() |
| 23 | { |
| 24 | return notif.getFieldOIDList(); |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | TEST_F(TestErrorNotification, VerifyErrorNotificationFields) |
| 29 | { |
| 30 | auto oidList = getFieldOIDList(); |
| 31 | |
| 32 | // verify the number of the fields in the notification. |
| 33 | EXPECT_EQ(ERROR_NOTIF_FIELD_COUNT, oidList.size()); |
| 34 | |
| 35 | // Verify the type of each field. |
| 36 | EXPECT_EQ(ASN_UNSIGNED, std::get<Type>(oidList[0])); |
| 37 | |
| 38 | EXPECT_EQ(ASN_OPAQUE_U64, std::get<Type>(oidList[1])); |
| 39 | EXPECT_EQ(ASN_INTEGER, std::get<Type>(oidList[2])); |
| 40 | EXPECT_EQ(ASN_OCTET_STR, std::get<Type>(oidList[3])); |
| 41 | } |
| 42 | |
| 43 | TEST_F(TestErrorNotification, GetASNType) |
| 44 | { |
| 45 | auto type = getASNType<uint32_t>(); |
| 46 | EXPECT_EQ(ASN_UNSIGNED, type); |
| 47 | |
| 48 | type = getASNType<uint64_t>(); |
| 49 | EXPECT_EQ(ASN_OPAQUE_U64, type); |
| 50 | |
| 51 | type = getASNType<int32_t>(); |
| 52 | EXPECT_EQ(ASN_INTEGER, type); |
| 53 | |
| 54 | type = getASNType<std::string>(); |
| 55 | EXPECT_EQ(ASN_OCTET_STR, type); |
| 56 | } |
| 57 | |
Ratan Gupta | aea53d0 | 2018-09-06 17:56:59 +0530 | [diff] [blame] | 58 | } // namespace snmp |
| 59 | } // namespace network |
Ratan Gupta | ec26fa6 | 2018-04-16 15:28:36 +0530 | [diff] [blame] | 60 | } // namespace phosphor |