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