blob: 5973f9285d4257d96bca25605136f5bdc892b871 [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
15const 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
48const 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
58TEST(PropertyWatchGenTest, storageCount)
59{
60 ASSERT_EQ(expectedStorageCount, storageCount);
61}
62
63TEST(PropertyWatchGenTest, IndiciesSameSize)
64{
Gunnar Mills78199b42017-10-25 16:30:18 -050065 ASSERT_EQ(sizeof(expectedIndicies), sizeof(indices));
Brad Bishop13fd8722017-05-15 12:44:01 -040066}
67
68TEST(PropertyWatchGenTest, WatchesSameSize)
69{
70 ASSERT_EQ(sizeof(expectedWatches), sizeof(watches));
71}
72
73TEST(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
83TEST(PropertyWatchGenTest, IndiciesSameContent)
84{
85 size_t i;
86 for (i = 0; i < expectedIndicies.size(); ++i)
87 {
Gunnar Mills78199b42017-10-25 16:30:18 -050088 ASSERT_EQ(indices[i],
Brad Bishop13fd8722017-05-15 12:44:01 -040089 expectedIndicies[i]);
90 }
91}