Improve error message for fullinertia and orientation specifiers.

Fixes #1888.

PiperOrigin-RevId: 661359190
Change-Id: Ibe38e88024b4a43922352b42347abf1026f168a2
This commit is contained in:
Alessio Quaglino
2024-08-09 12:19:26 -07:00
committed by Copybara-Service
parent ebd8615554
commit da15aa6a0e
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -3344,7 +3344,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* pbody, mjsFrame* frame,
bool alt = ReadAlternative(elem, pbody->ialt);
bool full = ReadAttr(elem, "fullinertia", 6, pbody->fullinertia, text);
if (alt && full) {
throw mjXError(elem, "multiple orientation specifiers are not allowed");
throw mjXError(elem, "fullinertia and orientation specifiers cannot be used together");
}
}
+4 -2
View File
@@ -1637,8 +1637,10 @@ TEST_F(XMLReaderTest, InvalidInertialOrientation) {
std::array<char, 1024> error;
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
ASSERT_THAT(model, IsNull());
EXPECT_THAT(error.data(),
HasSubstr("multiple orientation specifiers are not allowed"));
EXPECT_THAT(
error.data(),
HasSubstr(
"fullinertia and orientation specifiers cannot be used together"));
}
TEST_F(XMLReaderTest, ReadShellParameter) {