blob: 71a554a79f9c01a6be1614dcd614677aaeed6b90 [file] [log] [blame]
Ratan Guptaec26fa62018-04-16 15:28:36 +05301#include "snmp_notification.hpp"
Patrick Williams1334b7b2021-02-22 17:15:12 -06002
Ratan Guptaec26fa62018-04-16 15:28:36 +05303#include <netinet/in.h>
4
Patrick Williams1334b7b2021-02-22 17:15:12 -06005#include <gtest/gtest.h>
6
Ratan Guptaec26fa62018-04-16 15:28:36 +05307namespace phosphor
8{
9namespace network
10{
11namespace snmp
12{
13
14constexpr auto ERROR_NOTIF_FIELD_COUNT = 4;
15
16class 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
30TEST_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
45TEST_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 Guptaaea53d02018-09-06 17:56:59 +053060} // namespace snmp
61} // namespace network
Ratan Guptaec26fa62018-04-16 15:28:36 +053062} // namespace phosphor