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