summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2019-04-15 15:59:28 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2019-04-15 22:42:54 -0400
commita24855045867171309a54f0de6ac99761654aa34 (patch)
tree06ead24adf74e54aed9593dc853dd19ac4b9caa2 /test
parent1f4c70a8607f332a505002992825b66ce84a1cfd (diff)
downloadphosphor-inventory-manager-master.tar.gz
phosphor-inventory-manager-master.zip
serialization: adapt to filesystem API changesHEADmaster
The behavior of std::filesystem::path::append changed on its journey from experimental:: to std:: Add a testcase and adapt to the behavior change. Fixes: e6b21c74581c30ea635aabbbc08d0a56f8e27063 Change-Id: I4bdb43ea9b85933ec12ae0f4b609ec3a33d77d01 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rw-r--r--test/serialize_test.cpp23
2 files changed, 24 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 36f2b4f..393ff0a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,7 +23,7 @@ check_PROGRAMS += utils-test
serialize_test_SOURCES = serialize_test.cpp
serialize_test_CFLAGS = ${GTEST_CFLAGS} ${GMOCK_CFLAGS}
-serialize_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS}
+serialize_test_LDADD = ${GTEST_LIBS} ${GMOCK_LIBS} -lstdc++fs
serialize_test_LDFLAGS = ${OESDK_TESTCASE_FLAGS}
check_PROGRAMS += serialize-test
diff --git a/test/serialize_test.cpp b/test/serialize_test.cpp
index 4ed6446..7061978 100644
--- a/test/serialize_test.cpp
+++ b/test/serialize_test.cpp
@@ -1 +1,24 @@
#include "../serialize.hpp"
+
+#include <gtest/gtest.h>
+
+using namespace phosphor::inventory::manager;
+using namespace std::string_literals;
+
+TEST(SerializeTest, TestStoragePathNoSlashes)
+{
+ auto path = "foo/bar/baz"s;
+ auto iface = "xyz.foo"s;
+ auto p1 = detail::getStoragePath(path, iface);
+ auto p2 = fs::path(PIM_PERSIST_PATH "/foo/bar/baz/xyz.foo");
+ EXPECT_EQ(p1, p2);
+}
+
+TEST(SerializeTest, TestStoragePathSlashes)
+{
+ auto path = "/foo/bar/baz"s;
+ auto iface = "/xyz.foo"s;
+ auto p1 = detail::getStoragePath(path, iface);
+ auto p2 = fs::path(PIM_PERSIST_PATH "/foo/bar/baz/xyz.foo");
+ EXPECT_EQ(p1, p2);
+}
OpenPOWER on IntegriCloud