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