diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-05-15 12:44:01 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-19 16:21:51 -0400 |
commit | 13fd8722e616dd424cd585187fb0ef65f6316023 (patch) | |
tree | 6cc19d2a199392b7a6678de57f110461041544b2 /src/test/propertywatchgentest.cpp | |
parent | 4b916f139a9b3ccac76610f5e4da1fe0bb4dfd51 (diff) | |
download | phosphor-dbus-monitor-13fd8722e616dd424cd585187fb0ef65f6316023.tar.gz phosphor-dbus-monitor-13fd8722e616dd424cd585187fb0ef65f6316023.zip |
Add testcases for property watches
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I9e9266901414c71a34d9686f2a45bc4764602d53
Diffstat (limited to 'src/test/propertywatchgentest.cpp')
-rw-r--r-- | src/test/propertywatchgentest.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/test/propertywatchgentest.cpp b/src/test/propertywatchgentest.cpp new file mode 100644 index 0000000..afd9dbc --- /dev/null +++ b/src/test/propertywatchgentest.cpp @@ -0,0 +1,91 @@ +#include <array> +#include <string> +#include <gtest/gtest.h> +#include "data_types.hpp" + +using namespace std::string_literals; +using namespace phosphor::dbus::monitoring; + +using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>; + +#include "propertywatchgentest.hpp" + +auto expectedStorageCount = 16; + +const std::array<Index, 4> expectedIndicies = +{ + { + { + {Index::key_type{0, 0, 0}, 0}, + {Index::key_type{0, 1, 0}, 1}, + {Index::key_type{1, 0, 0}, 2}, + {Index::key_type{1, 1, 0}, 3}, + {Index::key_type{2, 0, 0}, 4}, + {Index::key_type{2, 1, 0}, 5}, + {Index::key_type{3, 0, 0}, 6}, + {Index::key_type{3, 1, 0}, 7}, + }, + { + {Index::key_type{2, 2, 1}, 8}, + {Index::key_type{2, 2, 2}, 9}, + {Index::key_type{3, 2, 1}, 10}, + {Index::key_type{3, 2, 2}, 11}, + {Index::key_type{4, 2, 1}, 12}, + {Index::key_type{4, 2, 2}, 13}, + {Index::key_type{5, 2, 1}, 14}, + {Index::key_type{5, 2, 2}, 15}, + }, + { + {Index::key_type{3, 0, 0}, 6}, + }, + { + {Index::key_type{3, 2, 2}, 11}, + {Index::key_type{5, 2, 2}, 15}, + }, + } +}; + +const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = +{ + { + std::tuple<std::string, size_t>{"std::string"s, 0}, + std::tuple<std::string, size_t>{"uint32_t"s, 1}, + std::tuple<std::string, size_t>{"int32_t"s, 2}, + std::tuple<std::string, size_t>{"std::string"s, 3}, + } +}; + +TEST(PropertyWatchGenTest, storageCount) +{ + ASSERT_EQ(expectedStorageCount, storageCount); +} + +TEST(PropertyWatchGenTest, IndiciesSameSize) +{ + ASSERT_EQ(sizeof(expectedIndicies), sizeof(indicies)); +} + +TEST(PropertyWatchGenTest, WatchesSameSize) +{ + ASSERT_EQ(sizeof(expectedWatches), sizeof(watches)); +} + +TEST(PropertyWatchGenTest, WatchesSameContent) +{ + size_t i; + for (i = 0; i < expectedWatches.size(); ++i) + { + ASSERT_EQ(watches[i], + expectedWatches[i]); + } +} + +TEST(PropertyWatchGenTest, IndiciesSameContent) +{ + size_t i; + for (i = 0; i < expectedIndicies.size(); ++i) + { + ASSERT_EQ(indicies[i], + expectedIndicies[i]); + } +} |