asset_manager.tests.cpp

 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
29
30
31
32
33
34
35
36
37
38
#include <planet/asset_manager.hpp>
#include <felspar/test.hpp>


namespace {


    auto const suite = felspar::testsuite("file_loader");
    auto const cwd = std::filesystem::current_path();
    auto const fn = suite.test("paths/filename", [](auto check) {
        planet::file_loader am{"./"};
        auto gen = am.search_paths();
        check(gen.next().value()) == cwd / "share/";
        check(gen.next().has_value()) == false;
    });
    auto const pn = suite.test("paths/pathname", [](auto check) {
        planet::file_loader am{"./path"};
        auto gen = am.search_paths();
        check(gen.next().value()) == cwd / "share/";
        check(gen.next().value()) == cwd / "path/share/";
        check(gen.next().has_value()) == false;
    });
    auto const rn = suite.test("paths/rootname", [](auto check) {
        planet::file_loader am{"/path"};
        auto gen = am.search_paths();
        check(gen.next().value()) == cwd / "share/";
#ifdef _WIN32
        check(gen.next().value()) == std::filesystem::path{"C:\\path\\share\\"};
        check(gen.next().value()) == std::filesystem::path{"C:\\share\\"};
#else
        check(gen.next().value()) == std::filesystem::path{"/path/share/"};
        check(gen.next().value()) == std::filesystem::path{"/share/"};
#endif
        check(gen.next().has_value()) == false;
    });


}