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 auto ERROR_NOTIF_FIELD_COUNT = 4; 15 16 class TestErrorNotification : public testing::Test 17 { 18 public: 19 OBMCErrorNotification notif; 20 TestErrorNotification() 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. 38 EXPECT_EQ(ASN_UNSIGNED, std::get<Type>(oidList[0])); 39 40 EXPECT_EQ(ASN_OPAQUE_U64, std::get<Type>(oidList[1])); 41 EXPECT_EQ(ASN_INTEGER, std::get<Type>(oidList[2])); 42 EXPECT_EQ(ASN_OCTET_STR, std::get<Type>(oidList[3])); 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 60 } // namespace snmp 61 } // namespace network 62 } // namespace phosphor 63