tesseract_urdf_mimic_unit.cpp
Go to the documentation of this file.
3 #include <gtest/gtest.h>
4 #include <Eigen/Geometry>
6 
8 #include <tesseract_urdf/mimic.h>
10 
11 TEST(TesseractURDFUnit, parse_mimic) // NOLINT
12 {
13  {
14  std::string str = R"(<mimic joint="joint_1" multiplier="1" offset="2" extra="0 0 0"/>)";
16  EXPECT_TRUE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
18  EXPECT_TRUE(elem->joint_name == "joint_1");
19  EXPECT_NEAR(elem->multiplier, 1, 1e-8);
20  EXPECT_NEAR(elem->offset, 2, 1e-8);
21  }
22 
23  {
24  std::string str = R"(<mimic joint="joint_1" multiplier="1"/>)";
26  EXPECT_TRUE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
28  EXPECT_TRUE(elem->joint_name == "joint_1");
29  EXPECT_NEAR(elem->multiplier, 1, 1e-8);
30  EXPECT_NEAR(elem->offset, 0, 1e-8);
31  }
32 
33  {
34  std::string str = R"(<mimic joint="joint_1" offset="2"/>)";
36  EXPECT_TRUE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
38  EXPECT_TRUE(elem->joint_name == "joint_1");
39  EXPECT_NEAR(elem->multiplier, 1, 1e-8);
40  EXPECT_NEAR(elem->offset, 2, 1e-8);
41  }
42 
43  {
44  std::string str = R"(<mimic joint="joint_1"/>)";
46  EXPECT_TRUE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
48  EXPECT_TRUE(elem->joint_name == "joint_1");
49  EXPECT_NEAR(elem->multiplier, 1, 1e-8);
50  EXPECT_NEAR(elem->offset, 0, 1e-8);
51  }
52 
53  {
54  std::string str = R"(<mimic joint="joint_1" multiplier="a" offset="2"/>)";
56  EXPECT_FALSE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
58  }
59 
60  {
61  std::string str = R"(<mimic joint="joint_1" multiplier="1" offset="a"/>)";
63  EXPECT_FALSE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
65  }
66 
67  {
68  std::string str = "<mimic />";
70  EXPECT_FALSE(runTest<tesseract_scene_graph::JointMimic::Ptr>(
72  }
73 }
74 
75 TEST(TesseractURDFUnit, write_mimic) // NOLINT
76 {
77  {
78  tesseract_scene_graph::JointMimic::Ptr mimic = std::make_shared<tesseract_scene_graph::JointMimic>();
79  std::string text;
80  EXPECT_EQ(0, writeTest<tesseract_scene_graph::JointMimic::Ptr>(mimic, &tesseract_urdf::writeMimic, text));
81  EXPECT_NE(text, "");
82  }
83 
84  {
86  std::string text;
87  EXPECT_EQ(1, writeTest<tesseract_scene_graph::JointMimic::Ptr>(mimic, &tesseract_urdf::writeMimic, text));
88  EXPECT_EQ(text, "");
89  }
90 }
joint.h
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
EXPECT_TRUE
#define EXPECT_TRUE(args)
tesseract_scene_graph::JointMimic::Ptr
std::shared_ptr< JointMimic > Ptr
tesseract_urdf_common_unit.h
EXPECT_NEAR
#define EXPECT_NEAR(a, b, prec)
tesseract_urdf::parseMimic
std::shared_ptr< tesseract_scene_graph::JointMimic > parseMimic(const tinyxml2::XMLElement *xml_element)
Parse xml element mimic.
Definition: mimic.cpp:42
TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_urdf::MIMIC_ELEMENT_NAME
static constexpr std::string_view MIMIC_ELEMENT_NAME
Definition: mimic.h:45
tesseract_urdf::writeMimic
tinyxml2::XMLElement * writeMimic(const std::shared_ptr< const tesseract_scene_graph::JointMimic > &mimic, tinyxml2::XMLDocument &doc)
Definition: mimic.cpp:66
macros.h
mimic.h
Parse mimic from xml string.
EXPECT_EQ
#define EXPECT_EQ(a, b)
EXPECT_FALSE
#define EXPECT_FALSE(args)
TEST
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH TESSERACT_COMMON_IGNORE_WARNINGS_POP TEST(TesseractURDFUnit, parse_mimic)
Definition: tesseract_urdf_mimic_unit.cpp:11


tesseract_urdf
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:07