blob: 580a820ac20c92fbfe0b67dcf735eb5276ad0806 [file] [log] [blame]
Ratan Guptaec26fa62018-04-16 15:28:36 +05301#include "snmp_notification.hpp"
2#include <gtest/gtest.h>
3#include <netinet/in.h>
4
5namespace phosphor
6{
7namespace network
8{
9namespace snmp
10{
11
12constexpr auto ERROR_NOTIF_FIELD_COUNT = 4;
13
14class 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
28TEST_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
43TEST_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 Guptaaea53d02018-09-06 17:56:59 +053058} // namespace snmp
59} // namespace network
Ratan Guptaec26fa62018-04-16 15:28:36 +053060} // namespace phosphor