25#ifndef TESSERACT_COMMON_UNIT_TEST_UTILS_H
26#define TESSERACT_COMMON_UNIT_TEST_UTILS_H
30#include <gtest/gtest.h>
31#include <boost/serialization/shared_ptr.hpp>
46template <
typename SerializableType>
51 EXPECT_TRUE(tesseract_common::Serialization::toArchiveFileXML<SerializableType>(
object,
file_path));
53 SerializableType nobject{ tesseract_common::Serialization::fromArchiveFileXML<SerializableType>(
file_path) };
59 EXPECT_TRUE(tesseract_common::Serialization::toArchiveFileBinary<SerializableType>(
object,
file_path));
61 SerializableType nobject{ tesseract_common::Serialization::fromArchiveFileBinary<SerializableType>(
file_path) };
66 std::string object_string =
67 tesseract_common::Serialization::toArchiveStringXML<SerializableType>(
object, typename_string);
70 SerializableType nobject{ tesseract_common::Serialization::fromArchiveStringXML<SerializableType>(object_string) };
82template <
typename SerializableType>
83void testSerializationPtr(
const std::shared_ptr<SerializableType>&
object,
const std::string& typename_string)
90 auto nobject = tesseract_common::Serialization::fromArchiveFileXML<std::shared_ptr<SerializableType>>(
file_path);
99 auto nobject = tesseract_common::Serialization::fromArchiveFileBinary<std::shared_ptr<SerializableType>>(
file_path);
104 std::string object_string =
105 tesseract_common::Serialization::toArchiveStringXML<std::shared_ptr<SerializableType>>(
object, typename_string);
109 tesseract_common::Serialization::fromArchiveStringXML<std::shared_ptr<SerializableType>>(object_string);
121template <
typename SerializableTypeBase,
typename SerializableTypeDerived>
123 const std::string& typename_string)
131 tesseract_common::Serialization::fromArchiveFileXML<std::shared_ptr<SerializableTypeBase>>(
file_path);
132 auto nobject_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(nobject);
134 auto object_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(
object);
144 tesseract_common::Serialization::fromArchiveFileBinary<std::shared_ptr<SerializableTypeBase>>(
file_path);
145 auto nobject_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(nobject);
147 auto object_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(
object);
152 std::string object_string =
153 tesseract_common::Serialization::toArchiveStringXML<std::shared_ptr<SerializableTypeBase>>(
object,
158 tesseract_common::Serialization::fromArchiveStringXML<std::shared_ptr<SerializableTypeBase>>(object_string);
159 auto nobject_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(nobject);
161 auto object_derived = std::dynamic_pointer_cast<SerializableTypeDerived>(
object);
EXPECT_FALSE(tesseract_collision::isContactAllowed("base_link", "link_2", acm, false))
EXPECT_TRUE(tesseract_common::isIdentical< tesseract_collision::ObjectPairKey >(pairs, check_pairs, false))
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: allowed_collision_matrix.h:16
void testSerializationPtr(const std::shared_ptr< SerializableType > &object, const std::string &typename_string)
Tests Boost serialization of shared pointer for a serializable type.
Definition: unit_test_utils.h:83
void testSerialization(const SerializableType &object, const std::string &typename_string)
Tests Boost serialization for a serializable type.
Definition: unit_test_utils.h:47
std::string getTempPath()
Get the host temp directory path.
Definition: utils.cpp:209
void testSerializationDerivedClass(const std::shared_ptr< SerializableTypeBase > &object, const std::string &typename_string)
Tests Boost serialization for a serializable derived type.
Definition: unit_test_utils.h:122
tesseract_common::fs::path file_path(__FILE__)
static bool toArchiveFileXML(const SerializableType &archive_type, const std::string &file_path, const std::string &name="")
Definition: serialization.h:112
static bool toArchiveFileBinary(const SerializableType &archive_type, const std::string &file_path, const std::string &name="")
Definition: serialization.h:137
Additional Boost serialization wrappers.
Common Tesseract Utility Functions.
tesseract_common::testSerialization< AllowedCollisionMatrix > * object
Definition: tesseract_common_serialization_unit.cpp:105