Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 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 | { |
| 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 | |
| 48 | const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = |
| 49 | { |
| 50 | { |
| 51 | std::tuple<std::string, size_t>{"std::string"s, 0}, |
| 52 | std::tuple<std::string, size_t>{"uint32_t"s, 1}, |
| 53 | std::tuple<std::string, size_t>{"int32_t"s, 2}, |
| 54 | std::tuple<std::string, size_t>{"std::string"s, 3}, |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | TEST(PropertyWatchGenTest, storageCount) |
| 59 | { |
| 60 | ASSERT_EQ(expectedStorageCount, storageCount); |
| 61 | } |
| 62 | |
| 63 | TEST(PropertyWatchGenTest, IndiciesSameSize) |
| 64 | { |
| 65 | ASSERT_EQ(sizeof(expectedIndicies), sizeof(indicies)); |
| 66 | } |
| 67 | |
| 68 | TEST(PropertyWatchGenTest, WatchesSameSize) |
| 69 | { |
| 70 | ASSERT_EQ(sizeof(expectedWatches), sizeof(watches)); |
| 71 | } |
| 72 | |
| 73 | TEST(PropertyWatchGenTest, WatchesSameContent) |
| 74 | { |
| 75 | size_t i; |
| 76 | for (i = 0; i < expectedWatches.size(); ++i) |
| 77 | { |
| 78 | ASSERT_EQ(watches[i], |
| 79 | expectedWatches[i]); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | TEST(PropertyWatchGenTest, IndiciesSameContent) |
| 84 | { |
| 85 | size_t i; |
| 86 | for (i = 0; i < expectedIndicies.size(); ++i) |
| 87 | { |
| 88 | ASSERT_EQ(indicies[i], |
| 89 | expectedIndicies[i]); |
| 90 | } |
| 91 | } |