summaryrefslogtreecommitdiffstats
path: root/src/test/pathgentest.cpp
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-05-07 23:14:57 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-04 22:40:30 -0400
commitb604480a43a25d0645b944fb16c1268d36782d36 (patch)
tree8732d567daf41e7adb6c32ae71c3fe15c89a914e /src/test/pathgentest.cpp
parent0e7df1317a055fd0a3e15fb46b1e78b6887ee2c8 (diff)
downloadphosphor-dbus-monitor-b604480a43a25d0645b944fb16c1268d36782d36.tar.gz
phosphor-dbus-monitor-b604480a43a25d0645b944fb16c1268d36782d36.zip
Add testcases for path and path group support
Change-Id: I296de0e0cb30e0e25f6677a06bd04fe15c2fd015 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'src/test/pathgentest.cpp')
-rw-r--r--src/test/pathgentest.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/test/pathgentest.cpp b/src/test/pathgentest.cpp
new file mode 100644
index 0000000..2199182
--- /dev/null
+++ b/src/test/pathgentest.cpp
@@ -0,0 +1,144 @@
+#include <array>
+#include <string>
+#include <gtest/gtest.h>
+#include "data_types.hpp"
+
+using namespace std::string_literals;
+using namespace phosphor::dbus::monitoring;
+using PathMeta = TupleOfRefs<const std::string, const std::string>;
+
+#include "pathgentest.hpp"
+
+const std::array<std::string, 3> expectedMeta =
+{
+ "path1"s,
+ "path3"s,
+ "path2"s,
+};
+
+const std::array<std::string, 6> expectedPaths =
+{
+ "/xyz/openbmc_project/testing/inst1"s,
+ "/xyz/openbmc_project/testing/inst2"s,
+ "/xyz/openbmc_project/testing/inst3"s,
+ "/xyz/openbmc_project/testing/inst4"s,
+ "/xyz/openbmc_project/testing/inst5"s,
+ "/xyz/openbmc_project/testing/inst6"s,
+};
+
+const std::array<PathMeta, 14> expectedPathMeta =
+{
+ {
+ PathMeta{ paths[0], meta[0] },
+ PathMeta{ paths[1], meta[0] },
+ PathMeta{ paths[2], meta[0] },
+ PathMeta{ paths[3], meta[0] },
+ PathMeta{ paths[0], meta[1] },
+ PathMeta{ paths[1], meta[1] },
+ PathMeta{ paths[2], meta[1] },
+ PathMeta{ paths[3], meta[1] },
+ PathMeta{ paths[4], meta[0] },
+ PathMeta{ paths[5], meta[0] },
+ PathMeta{ paths[3], meta[2] },
+ PathMeta{ paths[2], meta[2] },
+ PathMeta{ paths[1], meta[2] },
+ PathMeta{ paths[0], meta[2] },
+ }
+};
+
+const std::array<RefVector<const std::string>, 4> expectedGroups =
+{
+ {
+ {
+ paths[0],
+ paths[1],
+ paths[2],
+ paths[3],
+ },
+ {
+ paths[0],
+ paths[1],
+ paths[2],
+ paths[3],
+ },
+ {
+ paths[0],
+ paths[1],
+ paths[4],
+ paths[5],
+ },
+ {
+ paths[3],
+ paths[2],
+ paths[1],
+ paths[0],
+ },
+ }
+};
+
+TEST(PathGenTest, MetaSameSize)
+{
+ ASSERT_EQ(sizeof(expectedMeta), sizeof(meta));
+}
+
+TEST(PathGenTest, PathsSameSize)
+{
+ ASSERT_EQ(sizeof(expectedPaths), sizeof(paths));
+}
+
+TEST(PathGenTest, PathMetaSameSize)
+{
+ ASSERT_EQ(sizeof(expectedPathMeta), sizeof(pathMeta));
+}
+
+TEST(PathGenTest, GroupsSameSize)
+{
+ ASSERT_EQ(sizeof(expectedGroups), sizeof(groups));
+}
+
+TEST(PathGenTest, MetaSameContent)
+{
+ size_t i;
+ for (i = 0; i < expectedMeta.size(); ++i)
+ {
+ ASSERT_EQ(meta[i], expectedMeta[i]);
+ }
+}
+
+TEST(PathGenTest, PathsSameContent)
+{
+ size_t i;
+ for (i = 0; i < expectedPaths.size(); ++i)
+ {
+ ASSERT_EQ(paths[i], expectedPaths[i]);
+ }
+}
+
+TEST(PathGenTest, PathMetaSameContent)
+{
+ size_t i;
+ for (i = 0; i < expectedPathMeta.size(); ++i)
+ {
+ const auto& path = std::get<0>(pathMeta[i]).get();
+ const auto& expPath = std::get<0>(expectedPathMeta[i]).get();
+ const auto& meta = std::get<1>(pathMeta[i]).get();
+ const auto& expMeta = std::get<1>(expectedPathMeta[i]).get();
+
+ ASSERT_EQ(path, expPath);
+ ASSERT_EQ(meta, expMeta);
+ }
+}
+
+TEST(PathGenTest, GroupsSameContent)
+{
+ size_t i;
+ for (i = 0; i < expectedGroups.size(); ++i)
+ {
+ size_t j;
+ for (j = 0; j < groups[i].size(); ++j)
+ {
+ ASSERT_EQ(groups[i][j].get(), expectedGroups[i][j].get());
+
+ }
+ }
+}
OpenPOWER on IntegriCloud