blob: 2e446a4bdb84721767c9c4ff42b29d75a9d3670f [file] [log] [blame]
Brad Bishop13fd8722017-05-15 12:44:01 -04001#include <array>
2#include <string>
3#include <gtest/gtest.h>
4#include "data_types.hpp"
5
6using namespace std::string_literals;
7using namespace phosphor::dbus::monitoring;
8
9using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
10
11#include "propertywatchgentest.hpp"
12
13auto expectedStorageCount = 16;
14
Brad Bishopd1eac882018-03-29 10:34:05 -040015const std::array<Index, 4> expectedIndicies = {{
Brad Bishop13fd8722017-05-15 12:44:01 -040016 {
Brad Bishopd1eac882018-03-29 10:34:05 -040017 {Index::key_type{0, 0, 0}, 0},
18 {Index::key_type{0, 1, 0}, 1},
19 {Index::key_type{1, 0, 0}, 2},
20 {Index::key_type{1, 1, 0}, 3},
21 {Index::key_type{2, 0, 0}, 4},
22 {Index::key_type{2, 1, 0}, 5},
23 {Index::key_type{3, 0, 0}, 6},
24 {Index::key_type{3, 1, 0}, 7},
25 },
26 {
27 {Index::key_type{2, 2, 1}, 8},
28 {Index::key_type{2, 2, 2}, 9},
29 {Index::key_type{3, 2, 1}, 10},
30 {Index::key_type{3, 2, 2}, 11},
31 {Index::key_type{4, 2, 1}, 12},
32 {Index::key_type{4, 2, 2}, 13},
33 {Index::key_type{5, 2, 1}, 14},
34 {Index::key_type{5, 2, 2}, 15},
35 },
36 {
37 {Index::key_type{3, 0, 0}, 6},
38 },
39 {
40 {Index::key_type{3, 2, 2}, 11},
41 {Index::key_type{5, 2, 2}, 15},
42 },
43}};
Brad Bishop13fd8722017-05-15 12:44:01 -040044
Brad Bishopd1eac882018-03-29 10:34:05 -040045const std::array<std::tuple<std::string, size_t>, 4> expectedWatches = {{
46 std::tuple<std::string, size_t>{"std::string"s, 0},
47 std::tuple<std::string, size_t>{"uint32_t"s, 1},
48 std::tuple<std::string, size_t>{"int32_t"s, 2},
49 std::tuple<std::string, size_t>{"std::string"s, 3},
50}};
Brad Bishop13fd8722017-05-15 12:44:01 -040051
52TEST(PropertyWatchGenTest, storageCount)
53{
54 ASSERT_EQ(expectedStorageCount, storageCount);
55}
56
57TEST(PropertyWatchGenTest, IndiciesSameSize)
58{
Gunnar Mills78199b42017-10-25 16:30:18 -050059 ASSERT_EQ(sizeof(expectedIndicies), sizeof(indices));
Brad Bishop13fd8722017-05-15 12:44:01 -040060}
61
62TEST(PropertyWatchGenTest, WatchesSameSize)
63{
64 ASSERT_EQ(sizeof(expectedWatches), sizeof(watches));
65}
66
67TEST(PropertyWatchGenTest, WatchesSameContent)
68{
69 size_t i;
70 for (i = 0; i < expectedWatches.size(); ++i)
71 {
Brad Bishopd1eac882018-03-29 10:34:05 -040072 ASSERT_EQ(watches[i], expectedWatches[i]);
Brad Bishop13fd8722017-05-15 12:44:01 -040073 }
74}
75
76TEST(PropertyWatchGenTest, IndiciesSameContent)
77{
78 size_t i;
79 for (i = 0; i < expectedIndicies.size(); ++i)
80 {
Brad Bishopd1eac882018-03-29 10:34:05 -040081 ASSERT_EQ(indices[i], expectedIndicies[i]);
Brad Bishop13fd8722017-05-15 12:44:01 -040082 }
83}