feat: directory-based resource resolver
This commit is contained in:
parent
15e2abbada
commit
656549f039
12 changed files with 223 additions and 11 deletions
34
engine/tests/src/resource.cc
Normal file
34
engine/tests/src/resource.cc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "fishbone/client.h"
|
||||
#include "fishbone/resource.h"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstring>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace {
|
||||
class TestEngine : public fishbone::BaseEngine {
|
||||
public:
|
||||
TestEngine() {
|
||||
// TODO: Use abstraction instead of relying on POSIX
|
||||
char cwd[PATH_MAX];
|
||||
getcwd(cwd, PATH_MAX);
|
||||
this->resourceResolver = new fishbone::DirectoryResourceResolver({std::string(cwd) + "/testresources"});
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static const char* LOREM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut "
|
||||
"labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi "
|
||||
"ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum "
|
||||
"dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia "
|
||||
"deserunt mollit anim id est laborum.";
|
||||
|
||||
TEST_CASE("Directory loader") {
|
||||
TestEngine engine;
|
||||
|
||||
fishbone::Resource rsc(&engine, "lorem.txt");
|
||||
|
||||
REQUIRE(rsc.getBuffer() != NULL);
|
||||
REQUIRE(rsc.getSize() == strlen(LOREM));
|
||||
REQUIRE(strncmp(rsc.getBuffer(), LOREM, rsc.getSize()) == 0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue