Support directories in VFS via mj_addBufferVFS.
PiperOrigin-RevId: 655286683 Change-Id: I846376a0571d8df28d979beb5981a0cbccd7a04f
This commit is contained in:
committed by
Copybara-Service
parent
2746cb8559
commit
5ac5cfb618
@@ -30,7 +30,7 @@ using ::testing::NotNull;
|
||||
using UserVfsTest = MujocoTest;
|
||||
|
||||
static bool HasFile(const mjVFS* vfs, const std::string& filename) {
|
||||
mjResource* resource = mju_openResource(filename.c_str(), vfs, nullptr, 0);
|
||||
mjResource* resource = mju_openResource("", filename.c_str(), vfs, nullptr, 0);
|
||||
bool result = resource != nullptr;
|
||||
mju_closeResource(resource);
|
||||
return result;
|
||||
@@ -196,14 +196,13 @@ TEST_F(UserVfsTest, AddBufferRepeat) {
|
||||
mj_deleteVFS(&vfs);
|
||||
}
|
||||
|
||||
TEST_F(UserVfsTest, BufferStripPath) {
|
||||
TEST_F(UserVfsTest, BufferPath) {
|
||||
mjVFS vfs;
|
||||
mj_defaultVFS(&vfs);
|
||||
std::string buffer = "<mujoco/>";
|
||||
const void* ptr = static_cast<const void*>(buffer.c_str());
|
||||
mj_addBufferVFS(&vfs, "dir/model", ptr, buffer.size());
|
||||
EXPECT_TRUE(HasFile(&vfs, "MODEL"));
|
||||
EXPECT_TRUE(HasFile(&vfs, "dir\\model"));
|
||||
EXPECT_TRUE(HasFile(&vfs, "files/../dir/model"));
|
||||
mj_deleteVFS(&vfs);
|
||||
}
|
||||
|
||||
@@ -222,7 +221,7 @@ TEST_F(UserVfsTest, Timestamps) {
|
||||
mj_defaultVFS(&vfs);
|
||||
mj_addBufferVFS(&vfs, "cube.obj", cube, sizeof(cube));
|
||||
|
||||
mjResource* resource = mju_openResource("cube.obj", &vfs, nullptr, 0);
|
||||
mjResource* resource = mju_openResource("", "cube.obj", &vfs, nullptr, 0);
|
||||
|
||||
// same timestamps
|
||||
EXPECT_EQ(mju_isModifiedResource(resource, resource->timestamp), 0);
|
||||
|
||||
Reference in New Issue
Block a user