1*3d6d3182SPatrick Venture #include "data_types.hpp"
2*3d6d3182SPatrick Venture 
313fd8722SBrad Bishop #include <array>
413fd8722SBrad Bishop #include <string>
5*3d6d3182SPatrick Venture 
613fd8722SBrad Bishop #include <gtest/gtest.h>
713fd8722SBrad Bishop 
813fd8722SBrad Bishop using namespace std::string_literals;
913fd8722SBrad Bishop using namespace phosphor::dbus::monitoring;
1013fd8722SBrad Bishop 
1113fd8722SBrad Bishop using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
1213fd8722SBrad Bishop 
1313fd8722SBrad Bishop #include "propertywatchgentest.hpp"
1413fd8722SBrad Bishop 
1513fd8722SBrad Bishop auto expectedStorageCount = 16;
1613fd8722SBrad Bishop 
17d1eac88dSBrad Bishop const std::array<Index, 4> expectedIndicies = {{
1813fd8722SBrad Bishop     {
1913fd8722SBrad Bishop         {Index::key_type{0, 0, 0}, 0},
2013fd8722SBrad Bishop         {Index::key_type{0, 1, 0}, 1},
2113fd8722SBrad Bishop         {Index::key_type{1, 0, 0}, 2},
2213fd8722SBrad Bishop         {Index::key_type{1, 1, 0}, 3},
2313fd8722SBrad Bishop         {Index::key_type{2, 0, 0}, 4},
2413fd8722SBrad Bishop         {Index::key_type{2, 1, 0}, 5},
2513fd8722SBrad Bishop         {Index::key_type{3, 0, 0}, 6},
2613fd8722SBrad Bishop         {Index::key_type{3, 1, 0}, 7},
2713fd8722SBrad Bishop     },
2813fd8722SBrad Bishop     {
2913fd8722SBrad Bishop         {Index::key_type{2, 2, 1}, 8},
3013fd8722SBrad Bishop         {Index::key_type{2, 2, 2}, 9},
3113fd8722SBrad Bishop         {Index::key_type{3, 2, 1}, 10},
3213fd8722SBrad Bishop         {Index::key_type{3, 2, 2}, 11},
3313fd8722SBrad Bishop         {Index::key_type{4, 2, 1}, 12},
3413fd8722SBrad Bishop         {Index::key_type{4, 2, 2}, 13},
3513fd8722SBrad Bishop         {Index::key_type{5, 2, 1}, 14},
3613fd8722SBrad Bishop         {Index::key_type{5, 2, 2}, 15},
3713fd8722SBrad Bishop     },
3813fd8722SBrad Bishop     {
3913fd8722SBrad Bishop         {Index::key_type{3, 0, 0}, 6},
4013fd8722SBrad Bishop     },
4113fd8722SBrad Bishop     {
4213fd8722SBrad Bishop         {Index::key_type{3, 2, 2}, 11},
4313fd8722SBrad Bishop         {Index::key_type{5, 2, 2}, 15},
4413fd8722SBrad Bishop     },
45d1eac88dSBrad Bishop }};
4613fd8722SBrad Bishop 
47d1eac88dSBrad Bishop const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = {{
4813fd8722SBrad Bishop     std::tuple<std::string, size_t>{"std::string"s, 0},
4913fd8722SBrad Bishop     std::tuple<std::string, size_t>{"uint32_t"s, 1},
5013fd8722SBrad Bishop     std::tuple<std::string, size_t>{"int32_t"s, 2},
5113fd8722SBrad Bishop     std::tuple<std::string, size_t>{"std::string"s, 3},
52d1eac88dSBrad Bishop }};
5313fd8722SBrad Bishop 
TEST(PropertyWatchGenTest,storageCount)5413fd8722SBrad Bishop TEST(PropertyWatchGenTest, storageCount)
5513fd8722SBrad Bishop {
5613fd8722SBrad Bishop     ASSERT_EQ(expectedStorageCount, storageCount);
5713fd8722SBrad Bishop }
5813fd8722SBrad Bishop 
TEST(PropertyWatchGenTest,IndiciesSameSize)5913fd8722SBrad Bishop TEST(PropertyWatchGenTest, IndiciesSameSize)
6013fd8722SBrad Bishop {
6178199b44SGunnar Mills     ASSERT_EQ(sizeof(expectedIndicies), sizeof(indices));
6213fd8722SBrad Bishop }
6313fd8722SBrad Bishop 
TEST(PropertyWatchGenTest,WatchesSameSize)6413fd8722SBrad Bishop TEST(PropertyWatchGenTest, WatchesSameSize)
6513fd8722SBrad Bishop {
6613fd8722SBrad Bishop     ASSERT_EQ(sizeof(expectedWatches), sizeof(watches));
6713fd8722SBrad Bishop }
6813fd8722SBrad Bishop 
TEST(PropertyWatchGenTest,WatchesSameContent)6913fd8722SBrad Bishop TEST(PropertyWatchGenTest, WatchesSameContent)
7013fd8722SBrad Bishop {
7113fd8722SBrad Bishop     size_t i;
7213fd8722SBrad Bishop     for (i = 0; i < expectedWatches.size(); ++i)
7313fd8722SBrad Bishop     {
74d1eac88dSBrad Bishop         ASSERT_EQ(watches[i], expectedWatches[i]);
7513fd8722SBrad Bishop     }
7613fd8722SBrad Bishop }
7713fd8722SBrad Bishop 
TEST(PropertyWatchGenTest,IndiciesSameContent)7813fd8722SBrad Bishop TEST(PropertyWatchGenTest, IndiciesSameContent)
7913fd8722SBrad Bishop {
8013fd8722SBrad Bishop     size_t i;
8113fd8722SBrad Bishop     for (i = 0; i < expectedIndicies.size(); ++i)
8213fd8722SBrad Bishop     {
83d1eac88dSBrad Bishop         ASSERT_EQ(indices[i], expectedIndicies[i]);
8413fd8722SBrad Bishop     }
8513fd8722SBrad Bishop }
86