summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/unittests/testMaintenanceBits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/unittests/testMaintenanceBits.cpp')
-rw-r--r--gentoobrowse-api/unittests/testMaintenanceBits.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/gentoobrowse-api/unittests/testMaintenanceBits.cpp b/gentoobrowse-api/unittests/testMaintenanceBits.cpp
new file mode 100644
index 0000000..c7104d9
--- /dev/null
+++ b/gentoobrowse-api/unittests/testMaintenanceBits.cpp
@@ -0,0 +1,27 @@
+#define BOOST_TEST_MODULE TestMaintenanceBits
+#include <boost/test/unit_test.hpp>
+
+#include <maintenance/abstractFileProcessor.h>
+
+BOOST_AUTO_TEST_CASE( match )
+{
+ std::filesystem::path path { "metadata/md5-cache/app-admin/conky-1.10.6-r1" };
+ Gentoo::Service::PathParts pp { path.begin(), path.end() };
+ BOOST_REQUIRE_EQUAL(4, pp.size());
+ BOOST_CHECK_EQUAL("metadata", pp[0]);
+ BOOST_CHECK_EQUAL("md5-cache", pp[1]);
+}
+
+BOOST_AUTO_TEST_CASE( compose )
+{
+ // std::filesystem composes slightly differently to boost::filesystem
+ // Specifically "/base" / "/sub"
+ // boost => "/base/sub"
+ // std => "/sub"
+ std::filesystem::path base {"/base"}, file {"file"};
+ std::string sub {"/sub"};
+
+ std::filesystem::path comp = base / std::filesystem::path(sub).lexically_relative("/") / file;
+ BOOST_CHECK_EQUAL("/base/sub/file", comp);
+}
+