Patrick Venture | 3d6d318 | 2018-08-31 09:33:09 -0700 | [diff] [blame] | 1 | #include "data_types.hpp" |
| 2 | |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 3 | #include <array> |
| 4 | #include <string> |
Patrick Venture | 3d6d318 | 2018-08-31 09:33:09 -0700 | [diff] [blame] | 5 | |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 6 | #include <gtest/gtest.h> |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 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 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 17 | const std::array<Index, 4> expectedIndicies = {{ |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 18 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 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 | }}; |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 46 | |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 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 | }}; |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 53 | |
| 54 | TEST(PropertyWatchGenTest, storageCount) |
| 55 | { |
| 56 | ASSERT_EQ(expectedStorageCount, storageCount); |
| 57 | } |
| 58 | |
| 59 | TEST(PropertyWatchGenTest, IndiciesSameSize) |
| 60 | { |
Gunnar Mills | 78199b4 | 2017-10-25 16:30:18 -0500 | [diff] [blame] | 61 | ASSERT_EQ(sizeof(expectedIndicies), sizeof(indices)); |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | TEST(PropertyWatchGenTest, WatchesSameSize) |
| 65 | { |
| 66 | ASSERT_EQ(sizeof(expectedWatches), sizeof(watches)); |
| 67 | } |
| 68 | |
| 69 | TEST(PropertyWatchGenTest, WatchesSameContent) |
| 70 | { |
| 71 | size_t i; |
| 72 | for (i = 0; i < expectedWatches.size(); ++i) |
| 73 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 74 | ASSERT_EQ(watches[i], expectedWatches[i]); |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
| 78 | TEST(PropertyWatchGenTest, IndiciesSameContent) |
| 79 | { |
| 80 | size_t i; |
| 81 | for (i = 0; i < expectedIndicies.size(); ++i) |
| 82 | { |
Brad Bishop | d1eac88 | 2018-03-29 10:34:05 -0400 | [diff] [blame] | 83 | ASSERT_EQ(indices[i], expectedIndicies[i]); |
Brad Bishop | 13fd872 | 2017-05-15 12:44:01 -0400 | [diff] [blame] | 84 | } |
| 85 | } |