1 #include "snmp_notification.hpp"
2
3 #include <netinet/in.h>
4
5 #include <gtest/gtest.h>
6
7 namespace phosphor
8 {
9 namespace network
10 {
11 namespace snmp
12 {
13
14 constexpr size_t ERROR_NOTIF_FIELD_COUNT = 4;
15
16 class TestErrorNotification : public testing::Test
17 {
18 public:
19 OBMCErrorNotification notif;
TestErrorNotification()20 TestErrorNotification() : notif(0, 0, 0, "")
21 {
22 // Empty
23 }
getFieldOIDList()24 std::vector<Object> getFieldOIDList()
25 {
26 return notif.getFieldOIDList();
27 }
28 };
29
TEST_F(TestErrorNotification,VerifyErrorNotificationFields)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.
38 EXPECT_EQ(ASN_UNSIGNED, oidList[0].type);
39
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);
43 }
44
TEST_F(TestErrorNotification,GetASNType)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
60 } // namespace snmp
61 } // namespace network
62 } // namespace phosphor
63