1#include <Core/Resources/Resources.hpp>
2#include <catch2/catch_test_macros.hpp>
4#include <Core/Utils/StdFilesystem.hpp>
5namespace fs = ::std::filesystem;
10TEST_CASE(
"Core/Resources",
"[unittests][Core]" ) {
16 auto baseResourcesPath1 =
17 getResourcesPath(
reinterpret_cast<void*
>( getRadiumResourcesPath ),
"Resources/Radium" );
18 auto baseResourcesPath2 =
getResourcesPath(
reinterpret_cast<void*
>( dummy ),
"" );
20 auto baseResourcesPath4 =
getResourcesPath(
nullptr,
"hopeYouDontHaveAPathWithThisName" );
22 std::cout << radiumResourcesPath.value_or(
"not found" ) <<
"\n"
23 << radiumPluginPath.value_or(
"not found" ) <<
"\n"
24 << basePath.value_or(
"not found" ) <<
"\n"
25 << baseResourcesPath.value_or(
"not found" ) <<
"\n"
26 << baseResourcesPath1.value_or(
"not found" ) <<
"\n"
27 << baseResourcesPath2.value_or(
"not found" ) <<
"\n";
29 REQUIRE( baseResourcesPath1 == radiumResourcesPath );
30 REQUIRE( baseResourcesPath2 == basePath );
31 REQUIRE( baseResourcesPath2 == baseResourcesPath3 );
32 REQUIRE( !baseResourcesPath4 );
35 REQUIRE( defaultDataPath == fs::current_path().
string() );
40 REQUIRE( currentDataPath ==
"data/tmp/bar/" );
42 REQUIRE( currentDataPath ==
"data/tmp/bar/" );
44 REQUIRE( currentDataPath ==
"data/tmp/foo/" );
47 REQUIRE( currentDataPath == fs::current_path().
string() );
48 fs::remove(
"data/tmp/foo/" );
49 fs::remove(
"data/tmp/bar/" );
50 fs::remove(
"data/tmp/" );
Resources paths, plugins paths and data paths management for Radium.
std::string getDataPath()
Get the current data path.
std::string popDataPath()
Pop the current data path.
optional< std::string > getRadiumPluginsPath()
Get the path of Radium embedded plugins.
optional< std::string > getBasePath()
this one is always found, use optional for consistency ?
void pushDataPath(std::string datapath)
Push a new data path.
optional< std::string > getResourcesPath(void *symbol, const std::string &pattern)
Search for general resource path.
optional< std::string > getRadiumResourcesPath()
Get the path of Radium internal resources.