Add suffix to duplicated assets.

PiperOrigin-RevId: 588775467
Change-Id: I3a0d2a14601cf018b0c8c56728bd3ae22adb8ec2
This commit is contained in:
Alessio Quaglino
2023-12-07 06:45:55 -08:00
committed by Copybara-Service
parent e4359c04df
commit d12fe594d9
4 changed files with 76 additions and 35 deletions
+10
View File
@@ -0,0 +1,10 @@
<mujoco>
<asset>
<mesh file="cube.obj"/>
<mesh file="cube.obj"/>
</asset>
<worldbody>
<geom type="mesh" mesh="cube_0"/>
<geom type="mesh" mesh="cube_1"/>
</worldbody>
</mujoco>
+22
View File
@@ -14,6 +14,7 @@
// Tests for user/user_model.cc.
#include <array>
#include <string>
#include <gmock/gmock.h>
@@ -21,6 +22,7 @@
#include <absl/strings/str_format.h>
#include <mujoco/mjmodel.h>
#include <mujoco/mujoco.h>
#include "src/cc/array_safety.h"
#include "test/fixture.h"
namespace mujoco {
@@ -190,6 +192,26 @@ TEST_F(UserDataTest, AutoNUserSensor) {
mj_deleteModel(m);
}
// ------------- test duplicate names ------------------------------------------
TEST_F(UserDataTest, DuplicateNames) {
static const char* const kFilePath = "user/testdata/load_twice.xml";
const std::string xml_path = GetTestDataFilePath(kFilePath);
std::array<char, 1024> error;
mjModel* m = mj_loadXML(xml_path.c_str(), 0, error.data(), error.size());
EXPECT_THAT(m, NotNull()) << error.data();
EXPECT_THAT(m->nmesh, 2);
for (int i = 0; i < m->nmesh; i++) {
char mesh_name[mjMAXUINAME] = "";
util::strcat_arr(mesh_name, m->names + m->name_meshadr[i]);
EXPECT_THAT(std::string(mesh_name), "cube_" + std::to_string(i));
}
mj_deleteModel(m);
}
// ------------- test fusestatic -----------------------------------------------
using FuseStaticTest = MujocoTest;