tesseract_urdf_sphere_unit.cpp
Go to the documentation of this file.
3 #include <gtest/gtest.h>
4 #include <Eigen/Geometry>
6 
10 
11 TEST(TesseractURDFUnit, parse_sphere) // NOLINT
12 {
13  {
14  std::string str = R"(<sphere radius="1" extra="0 0 0"/>)";
16  EXPECT_TRUE(runTest<tesseract_geometry::Sphere::Ptr>(
18  EXPECT_NEAR(geom->getRadius(), 1, 1e-8);
19  }
20 
21  { // https://github.com/ros-industrial-consortium/tesseract_ros/issues/67
22  std::string str = R"(<sphere radius="0.25" extra="0 0 0"/>)";
24  EXPECT_TRUE(runTest<tesseract_geometry::Sphere::Ptr>(
26  EXPECT_NEAR(geom->getRadius(), 0.25, 1e-8);
27  }
28 
29  {
30  std::string str = R"(<sphere radius="-1" extra="0 0 0"/>)";
32  EXPECT_FALSE(runTest<tesseract_geometry::Sphere::Ptr>(
34  }
35 
36  {
37  std::string str = R"(<sphere radius="a"/>)";
39  EXPECT_FALSE(runTest<tesseract_geometry::Sphere::Ptr>(
41  }
42 
43  // TODO: I would expect this to fail but tinyxml2 still parses it so need to create an issue.
44  // {
45  // std::string str = R"(<sphere radius="1 2"/>)";
46  // tesseract_geometry::Sphere::Ptr geom;
47  // auto status = runTest<tesseract_geometry::Sphere::Ptr>(geom, str, tesseract_urdf::SPHERE_ELEMENT_NAME.data());
48  // EXPECT_FALSE(*status);
49  // EXPECT_FALSE(status->message().empty());
50  // }
51 
52  {
53  std::string str = R"(<sphere />)";
55  EXPECT_FALSE(runTest<tesseract_geometry::Sphere::Ptr>(
57  }
58 }
59 
60 TEST(TesseractURDFUnit, write_sphere) // NOLINT
61 {
62  {
63  tesseract_geometry::Sphere::Ptr geom = std::make_shared<tesseract_geometry::Sphere>(1.0);
64  std::string text;
65  EXPECT_EQ(0, writeTest<tesseract_geometry::Sphere::Ptr>(geom, &tesseract_urdf::writeSphere, text));
66  EXPECT_NE(text, "");
67  }
68 
69  {
70  tesseract_geometry::Sphere::Ptr geom = nullptr;
71  std::string text;
72  EXPECT_EQ(1, writeTest<tesseract_geometry::Sphere::Ptr>(geom, &tesseract_urdf::writeSphere, text));
73  EXPECT_EQ(text, "");
74  }
75 }
tesseract_urdf::parseSphere
std::shared_ptr< tesseract_geometry::Sphere > parseSphere(const tinyxml2::XMLElement *xml_element)
Parse a xml sphere element.
Definition: sphere.cpp:40
tesseract_urdf::SPHERE_ELEMENT_NAME
static constexpr std::string_view SPHERE_ELEMENT_NAME
Definition: sphere.h:45
sphere.h
Parse sphere from xml string.
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
EXPECT_TRUE
#define EXPECT_TRUE(args)
tesseract_urdf_common_unit.h
EXPECT_NEAR
#define EXPECT_NEAR(a, b, prec)
sphere.h
TESSERACT_COMMON_IGNORE_WARNINGS_POP
TEST
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH TESSERACT_COMMON_IGNORE_WARNINGS_POP TEST(TesseractURDFUnit, parse_sphere)
Definition: tesseract_urdf_sphere_unit.cpp:11
tesseract_urdf::writeSphere
tinyxml2::XMLElement * writeSphere(const std::shared_ptr< const tesseract_geometry::Sphere > &sphere, tinyxml2::XMLDocument &doc)
Definition: sphere.cpp:49
tesseract_geometry::Sphere::Ptr
std::shared_ptr< Sphere > Ptr
macros.h
EXPECT_EQ
#define EXPECT_EQ(a, b)
EXPECT_FALSE
#define EXPECT_FALSE(args)


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