1*13fd8722SBrad Bishop #include <array>
2*13fd8722SBrad Bishop #include <string>
3*13fd8722SBrad Bishop #include <gtest/gtest.h>
4*13fd8722SBrad Bishop #include "data_types.hpp"
5*13fd8722SBrad Bishop 
6*13fd8722SBrad Bishop using namespace std::string_literals;
7*13fd8722SBrad Bishop using namespace phosphor::dbus::monitoring;
8*13fd8722SBrad Bishop 
9*13fd8722SBrad Bishop using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
10*13fd8722SBrad Bishop 
11*13fd8722SBrad Bishop #include "propertywatchgentest.hpp"
12*13fd8722SBrad Bishop 
13*13fd8722SBrad Bishop auto expectedStorageCount = 16;
14*13fd8722SBrad Bishop 
15*13fd8722SBrad Bishop const std::array<Index, 4> expectedIndicies =
16*13fd8722SBrad Bishop {
17*13fd8722SBrad Bishop     {
18*13fd8722SBrad Bishop         {
19*13fd8722SBrad Bishop             {Index::key_type{0, 0, 0}, 0},
20*13fd8722SBrad Bishop             {Index::key_type{0, 1, 0}, 1},
21*13fd8722SBrad Bishop             {Index::key_type{1, 0, 0}, 2},
22*13fd8722SBrad Bishop             {Index::key_type{1, 1, 0}, 3},
23*13fd8722SBrad Bishop             {Index::key_type{2, 0, 0}, 4},
24*13fd8722SBrad Bishop             {Index::key_type{2, 1, 0}, 5},
25*13fd8722SBrad Bishop             {Index::key_type{3, 0, 0}, 6},
26*13fd8722SBrad Bishop             {Index::key_type{3, 1, 0}, 7},
27*13fd8722SBrad Bishop         },
28*13fd8722SBrad Bishop         {
29*13fd8722SBrad Bishop             {Index::key_type{2, 2, 1}, 8},
30*13fd8722SBrad Bishop             {Index::key_type{2, 2, 2}, 9},
31*13fd8722SBrad Bishop             {Index::key_type{3, 2, 1}, 10},
32*13fd8722SBrad Bishop             {Index::key_type{3, 2, 2}, 11},
33*13fd8722SBrad Bishop             {Index::key_type{4, 2, 1}, 12},
34*13fd8722SBrad Bishop             {Index::key_type{4, 2, 2}, 13},
35*13fd8722SBrad Bishop             {Index::key_type{5, 2, 1}, 14},
36*13fd8722SBrad Bishop             {Index::key_type{5, 2, 2}, 15},
37*13fd8722SBrad Bishop         },
38*13fd8722SBrad Bishop         {
39*13fd8722SBrad Bishop             {Index::key_type{3, 0, 0}, 6},
40*13fd8722SBrad Bishop         },
41*13fd8722SBrad Bishop         {
42*13fd8722SBrad Bishop             {Index::key_type{3, 2, 2}, 11},
43*13fd8722SBrad Bishop             {Index::key_type{5, 2, 2}, 15},
44*13fd8722SBrad Bishop         },
45*13fd8722SBrad Bishop     }
46*13fd8722SBrad Bishop };
47*13fd8722SBrad Bishop 
48*13fd8722SBrad Bishop const std::array<std::tuple<std::string, size_t>, 4> expectedWatches =
49*13fd8722SBrad Bishop {
50*13fd8722SBrad Bishop     {
51*13fd8722SBrad Bishop         std::tuple<std::string, size_t>{"std::string"s, 0},
52*13fd8722SBrad Bishop         std::tuple<std::string, size_t>{"uint32_t"s, 1},
53*13fd8722SBrad Bishop         std::tuple<std::string, size_t>{"int32_t"s, 2},
54*13fd8722SBrad Bishop         std::tuple<std::string, size_t>{"std::string"s, 3},
55*13fd8722SBrad Bishop     }
56*13fd8722SBrad Bishop };
57*13fd8722SBrad Bishop 
58*13fd8722SBrad Bishop TEST(PropertyWatchGenTest, storageCount)
59*13fd8722SBrad Bishop {
60*13fd8722SBrad Bishop     ASSERT_EQ(expectedStorageCount, storageCount);
61*13fd8722SBrad Bishop }
62*13fd8722SBrad Bishop 
63*13fd8722SBrad Bishop TEST(PropertyWatchGenTest, IndiciesSameSize)
64*13fd8722SBrad Bishop {
65*13fd8722SBrad Bishop     ASSERT_EQ(sizeof(expectedIndicies), sizeof(indicies));
66*13fd8722SBrad Bishop }
67*13fd8722SBrad Bishop 
68*13fd8722SBrad Bishop TEST(PropertyWatchGenTest, WatchesSameSize)
69*13fd8722SBrad Bishop {
70*13fd8722SBrad Bishop     ASSERT_EQ(sizeof(expectedWatches), sizeof(watches));
71*13fd8722SBrad Bishop }
72*13fd8722SBrad Bishop 
73*13fd8722SBrad Bishop TEST(PropertyWatchGenTest, WatchesSameContent)
74*13fd8722SBrad Bishop {
75*13fd8722SBrad Bishop     size_t i;
76*13fd8722SBrad Bishop     for (i = 0; i < expectedWatches.size(); ++i)
77*13fd8722SBrad Bishop     {
78*13fd8722SBrad Bishop         ASSERT_EQ(watches[i],
79*13fd8722SBrad Bishop                   expectedWatches[i]);
80*13fd8722SBrad Bishop     }
81*13fd8722SBrad Bishop }
82*13fd8722SBrad Bishop 
83*13fd8722SBrad Bishop TEST(PropertyWatchGenTest, IndiciesSameContent)
84*13fd8722SBrad Bishop {
85*13fd8722SBrad Bishop     size_t i;
86*13fd8722SBrad Bishop     for (i = 0; i < expectedIndicies.size(); ++i)
87*13fd8722SBrad Bishop     {
88*13fd8722SBrad Bishop         ASSERT_EQ(indicies[i],
89*13fd8722SBrad Bishop                   expectedIndicies[i]);
90*13fd8722SBrad Bishop     }
91*13fd8722SBrad Bishop }
92