summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/unittests/testMaintenanceBits.cpp
blob: f51014896681281ea350d515ca65ef4728bc4eb4 (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
27
28
#define BOOST_TEST_MODULE TestMaintenanceBits
#include <boost/test/unit_test.hpp>

#include "maintenance/abstractFileProcessor.h"
#include <filesystem>
#include <string>

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);
}