Add private function mju_isZeroByte to check for byte-wise zero.

PiperOrigin-RevId: 810456282
Change-Id: I877d0f9225e7a783ed7ff12ce54f4ed0a7889793
This commit is contained in:
Yuval Tassa
2025-09-23 08:48:43 -07:00
committed by Copybara-Service
parent bb0878417e
commit d71d42a374
8 changed files with 128 additions and 6 deletions
+11
View File
@@ -349,6 +349,17 @@ TEST_F(UtilMiscTest, MjuSparseLower2SymMapPartial) {
EXPECT_THAT(AsVector(mat_res, res_nnz), ElementsAre(1, 2, 0, 2, 3, 0, 6));
}
TEST_F(UtilMiscTest, MjuIsZero) {
mjtNum vec[1] = {1};
EXPECT_EQ(mju_isZero(vec, 1), 0);
EXPECT_EQ(mju_isZero(vec, 0), 1);
vec[0] = 0;
EXPECT_EQ(mju_isZero(vec, 1), 1);
vec[0] = -0.0;
EXPECT_EQ(mju_isZero(vec, 1), 1);
EXPECT_EQ(mju_isZeroByte((const unsigned char*)vec, sizeof(mjtNum)), 0);
}
// --------------------------------- Interpolation -----------------------------
using InterpolationTest = MujocoTest;