1 #include <array> 2 #include <string> 3 #include <gtest/gtest.h> 4 #include "data_types.hpp" 5 6 using namespace std::string_literals; 7 using namespace phosphor::dbus::monitoring; 8 9 using Property = 10 TupleOfRefs<const std::string, const std::string, const std::string>; 11 12 using GroupOfProperties = std::vector<::Property>; 13 14 #include "propertygentest.hpp" 15 const std::array<std::string, 3> expectedMeta = { 16 "PROPERTY1"s, 17 "PROPERTY2"s, 18 "PROPERTY3"s, 19 }; 20 21 const std::array<std::string, 4> expectedInterfaces = { 22 "xyz.openbmc_project.Test.Iface3"s, 23 "xyz.openbmc_project.Test.Iface2"s, 24 "xyz.openbmc_project.Test.Iface6"s, 25 "xyz.openbmc_project.Test.Iface1"s, 26 }; 27 28 const std::array<std::string, 4> expectedProperties = { 29 "Foo"s, 30 "Value"s, 31 "Bar"s, 32 "Baz"s, 33 }; 34 35 const std::array<GroupOfProperties, 4> expectedGroups = {{ 36 { 37 ::Property{interfaces[0], properties[0], meta[0]}, 38 ::Property{interfaces[1], properties[1], meta[1]}, 39 }, 40 { 41 ::Property{interfaces[0], properties[2], meta[0]}, 42 ::Property{interfaces[1], properties[0], meta[1]}, 43 }, 44 { 45 ::Property{interfaces[2], properties[0], meta[0]}, 46 ::Property{interfaces[3], properties[1], meta[1]}, 47 }, 48 { 49 ::Property{interfaces[0], properties[2], meta[0]}, 50 ::Property{interfaces[1], properties[1], meta[1]}, 51 ::Property{interfaces[2], properties[3], meta[2]}, 52 }, 53 }}; 54 55 const std::array<std::string, 4> expectedTypes = { 56 "uint32_t"s, 57 "int32_t"s, 58 "std::string"s, 59 "int32_t"s, 60 }; 61 62 TEST(PropertyGenTest, MetaSameSize) 63 { 64 ASSERT_EQ(sizeof(expectedMeta), sizeof(meta)); 65 } 66 67 TEST(PropertyGenTest, IfacesSameSize) 68 { 69 ASSERT_EQ(sizeof(expectedInterfaces), sizeof(interfaces)); 70 } 71 72 TEST(PropertyGenTest, PropertiesSameSize) 73 { 74 ASSERT_EQ(sizeof(expectedProperties), sizeof(properties)); 75 } 76 77 TEST(PropertyGenTest, GroupsSameSize) 78 { 79 ASSERT_EQ(sizeof(expectedGroups), sizeof(groups)); 80 } 81 82 TEST(PropertyGenTest, TypesSameSize) 83 { 84 ASSERT_EQ(sizeof(expectedTypes), sizeof(types)); 85 } 86 87 TEST(PropertyGenTest, MetaSameContent) 88 { 89 size_t i; 90 for (i = 0; i < expectedMeta.size(); ++i) 91 { 92 ASSERT_EQ(meta[i], expectedMeta[i]); 93 } 94 } 95 96 TEST(PropertyGenTest, IfacesSameContent) 97 { 98 size_t i; 99 for (i = 0; i < expectedInterfaces.size(); ++i) 100 { 101 ASSERT_EQ(interfaces[i], expectedInterfaces[i]); 102 } 103 } 104 105 TEST(PropertyGenTest, PropertiesSameContent) 106 { 107 size_t i; 108 for (i = 0; i < expectedProperties.size(); ++i) 109 { 110 ASSERT_EQ(expectedProperties[i], properties[i]); 111 } 112 } 113 114 TEST(PropertyGenTest, GroupsSameContent) 115 { 116 size_t i; 117 for (i = 0; i < expectedGroups.size(); ++i) 118 { 119 size_t j; 120 for (j = 0; j < expectedGroups[i].size(); ++j) 121 { 122 const auto& expectedIface = std::get<0>(expectedGroups[i][j]).get(); 123 const auto& actualIface = std::get<0>(groups[i][j]).get(); 124 ASSERT_EQ(expectedIface, actualIface); 125 126 const auto& expectedProperty = 127 std::get<1>(expectedGroups[i][j]).get(); 128 const auto& actualProperty = std::get<1>(groups[i][j]).get(); 129 ASSERT_EQ(expectedProperty, actualProperty); 130 131 const auto& expectedMeta = std::get<1>(expectedGroups[i][j]).get(); 132 const auto& actualMeta = std::get<1>(groups[i][j]).get(); 133 ASSERT_EQ(expectedMeta, actualMeta); 134 } 135 } 136 } 137 138 TEST(PropertyGenTest, TypesSameContent) 139 { 140 size_t i; 141 for (i = 0; i < expectedTypes.size(); ++i) 142 { 143 ASSERT_EQ(expectedTypes[i], types[i]); 144 } 145 } 146