tesseract_urdf_box_unit.cpp
Go to the documentation of this file.
3 #include <gtest/gtest.h>
4 #include <Eigen/Geometry>
6 
7 #include <tesseract_urdf/box.h>
10 
11 TEST(TesseractURDFUnit, parse_box) // NOLINT
12 {
13  {
14  std::string str = R"(<box size="1 2.0 3" extra="0 0 0"/>)";
16  EXPECT_TRUE(runTest<tesseract_geometry::Box::Ptr>(
18  EXPECT_NEAR(geom->getX(), 1, 1e-8);
19  EXPECT_NEAR(geom->getY(), 2, 1e-8);
20  EXPECT_NEAR(geom->getZ(), 3, 1e-8);
21  }
22 
23  { // https://github.com/ros-industrial-consortium/tesseract_ros/issues/67
24  std::string str = R"(<box size="0.5 0.25 0.75" extra="0 0 0"/>)";
26  EXPECT_TRUE(runTest<tesseract_geometry::Box::Ptr>(
28  EXPECT_NEAR(geom->getX(), 0.5, 1e-8);
29  EXPECT_NEAR(geom->getY(), 0.25, 1e-8);
30  EXPECT_NEAR(geom->getZ(), 0.75, 1e-8);
31  }
32 
33  {
34  std::string str = R"(<box size="-1 2.0 3" extra="0 0 0"/>)";
36  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
38  }
39 
40  {
41  std::string str = R"(<box size="1 -2.0 3" extra="0 0 0"/>)";
43  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
45  }
46 
47  {
48  std::string str = R"(<box size="1 2.0 -3" extra="0 0 0"/>)";
50  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
52  }
53 
54  {
55  std::string str = R"(<box size="1.0 2 a"/>)";
57  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
59  }
60 
61  {
62  std::string str = R"(<box size="1 2"/>)";
64  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
66  }
67 
68  {
69  std::string str = "<box />";
71  EXPECT_FALSE(runTest<tesseract_geometry::Box::Ptr>(
73  }
74 }
75 
76 TEST(TesseractURDFUnit, write_box) // NOLINT
77 {
78  {
79  tesseract_geometry::Box::Ptr geom = std::make_shared<tesseract_geometry::Box>(1.0, 2.0, 3.0);
80  std::string text;
81  EXPECT_EQ(0, writeTest<tesseract_geometry::Box::Ptr>(geom, &tesseract_urdf::writeBox, text));
82  EXPECT_EQ(text, R"(<box size="1 2 3"/>)");
83  }
84 
85  {
86  tesseract_geometry::Box::Ptr geom = nullptr;
87  std::string text;
88  EXPECT_EQ(1, writeTest<tesseract_geometry::Box::Ptr>(geom, &tesseract_urdf::writeBox, text));
89  EXPECT_EQ(text, "");
90  }
91 }
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_urdf::BOX_ELEMENT_NAME
static constexpr std::string_view BOX_ELEMENT_NAME
Definition: box.h:45
EXPECT_TRUE
#define EXPECT_TRUE(args)
box.h
Parse box from xml string.
tesseract_urdf_common_unit.h
EXPECT_NEAR
#define EXPECT_NEAR(a, b, prec)
TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_urdf::parseBox
std::shared_ptr< tesseract_geometry::Box > parseBox(const tinyxml2::XMLElement *xml_element)
Parse a xml box element.
Definition: box.cpp:41
tesseract_geometry::Box::Ptr
std::shared_ptr< Box > Ptr
tesseract_urdf::writeBox
tinyxml2::XMLElement * writeBox(const std::shared_ptr< const tesseract_geometry::Box > &box, tinyxml2::XMLDocument &doc)
Definition: box.cpp:70
macros.h
box.h
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_box)
Definition: tesseract_urdf_box_unit.cpp:11


tesseract_urdf
Author(s): Levi Armstrong
autogenerated on Thu Apr 24 2025 03:10:44