fix io::path.parent() & update tests
This commit is contained in:
parent
a653b063e6
commit
e4c33e539e
@ -110,13 +110,9 @@ namespace io {
|
||||
path parent() const {
|
||||
size_t slashpos = str.rfind('/');
|
||||
if (slashpos == std::string::npos) {
|
||||
return colonPos == std::string::npos
|
||||
? path()
|
||||
: path(str.substr(0, colonPos));
|
||||
return colonPos == std::string::npos ? "" : str;
|
||||
}
|
||||
return colonPos == std::string::npos
|
||||
? path(str.substr(0, slashpos))
|
||||
: path(str.substr(0, colonPos) + str.substr(slashpos));
|
||||
return str.substr(0, slashpos);
|
||||
}
|
||||
|
||||
std::string string() const {
|
||||
|
||||
@ -3,10 +3,14 @@
|
||||
#include "coders/commons.hpp"
|
||||
#include "coders/lua_parsing.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "io/devices/StdfsDevice.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
TEST(lua_parsing, Tokenizer) {
|
||||
auto filename = "../../res/scripts/stdlib.lua";
|
||||
io::set_device("res", std::make_shared<io::StdfsDevice>(fs::u8path("../../res")));
|
||||
auto filename = "res:scripts/stdlib.lua";
|
||||
auto source = io::read_string(filename);
|
||||
try {
|
||||
auto tokens = lua::tokenize(filename, source);
|
||||
|
||||
@ -2,9 +2,13 @@
|
||||
|
||||
#include "coders/vec3.hpp"
|
||||
#include "io/io.hpp"
|
||||
#include "io/devices/StdfsDevice.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
TEST(VEC3, Decode) {
|
||||
io::path file = "res/models/block.vec3";
|
||||
io::set_device("res", std::make_shared<io::StdfsDevice>(fs::u8path("../../res")));
|
||||
io::path file = "res:models/block.vec3";
|
||||
auto bytes = io::read_bytes_buffer(file);
|
||||
auto model = vec3::load(file.string(), bytes);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user