blob: b1fe6c418501277792c246b8ef906f505637017e [file] [log] [blame]
Patrick Venture3d6d3182018-08-31 09:33:09 -07001#include "data_types.hpp"
2
Brad Bishop13fd8722017-05-15 12:44:01 -04003#include <array>
4#include <string>
Patrick Venture3d6d3182018-08-31 09:33:09 -07005
Brad Bishop13fd8722017-05-15 12:44:01 -04006#include <gtest/gtest.h>
Brad Bishop13fd8722017-05-15 12:44:01 -04007
8using namespace std::string_literals;
9using namespace phosphor::dbus::monitoring;
10
11using Index = std::map<std::tuple<size_t, size_t, size_t>, size_t>;
12
13#include "propertywatchgentest.hpp"
14
15auto expectedStorageCount = 16;
16
Brad Bishopd1eac882018-03-29 10:34:05 -040017const std::array<Index, 4> expectedIndicies = {{
Brad Bishop13fd8722017-05-15 12:44:01 -040018 {
Brad Bishopd1eac882018-03-29 10:34:05 -040019 {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 Bishop13fd8722017-05-15 12:44:01 -040046
Brad Bishopd1eac882018-03-29 10:34:05 -040047const 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 Bishop13fd8722017-05-15 12:44:01 -040053
54TEST(PropertyWatchGenTest, storageCount)
55{
56 ASSERT_EQ(expectedStorageCount, storageCount);
57}
58
59TEST(PropertyWatchGenTest, IndiciesSameSize)
60{
Gunnar Mills78199b42017-10-25 16:30:18 -050061 ASSERT_EQ(sizeof(expectedIndicies), sizeof(indices));
Brad Bishop13fd8722017-05-15 12:44:01 -040062}
63
64TEST(PropertyWatchGenTest, WatchesSameSize)
65{
66 ASSERT_EQ(sizeof(expectedWatches), sizeof(watches));
67}
68
69TEST(PropertyWatchGenTest, WatchesSameContent)
70{
71 size_t i;
72 for (i = 0; i < expectedWatches.size(); ++i)
73 {
Brad Bishopd1eac882018-03-29 10:34:05 -040074 ASSERT_EQ(watches[i], expectedWatches[i]);
Brad Bishop13fd8722017-05-15 12:44:01 -040075 }
76}
77
78TEST(PropertyWatchGenTest, IndiciesSameContent)
79{
80 size_t i;
81 for (i = 0; i < expectedIndicies.size(); ++i)
82 {
Brad Bishopd1eac882018-03-29 10:34:05 -040083 ASSERT_EQ(indices[i], expectedIndicies[i]);
Brad Bishop13fd8722017-05-15 12:44:01 -040084 }
85}