Fixing crash on windows when uFormat() is to long

This commit is contained in:
matlabbe
2026-10-11 11:45:52 -07:00
parent 526c422643
commit 05b5661e6b
6 changed files with 37 additions and 4 deletions
+1
View File
@@ -42,6 +42,7 @@ set(corelib_test_sources
test_link.cpp #Link.h
test_optimizer.cpp #Optimizer.h
test_gps.cpp #GPS.h
test_parameters.cpp #Parameters.h
test_imu.cpp #IMU.h
test_imufilter.cpp #IMUFilter.h
test_imumotionpredictor.cpp #ImuMotionPredictor.h
+20
View File
@@ -0,0 +1,20 @@
#include <gtest/gtest.h>
#include <rtabmap/core/Parameters.h>
using rtabmap::Parameters;
using rtabmap::ParametersMap;
TEST(Parameters, descriptions_are_shorter_than_1024_characters)
{
// Long descriptions don't fit in the GUI's tooltips nor in a ROS parameter listing:
// keep them short, the details belong in the documentation. 1024 was also the size
// beyond which uFormat(), which formats most of them, aborted on Windows.
const ParametersMap & parameters = Parameters::getDefaultParameters();
ASSERT_FALSE(parameters.empty());
for(ParametersMap::const_iterator iter = parameters.begin(); iter != parameters.end(); ++iter)
{
const std::string description = Parameters::getDescription(iter->first);
EXPECT_LT(description.size(), 1024u) << iter->first << " has a description of "
<< description.size() << " characters: shorten it";
}
}