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