blob: 9c16f74d91c5e96b43cf1e82ba8f0de2f97bc390 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#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);
}
|