Tesseract 0.28.4
Loading...
Searching...
No Matches
unit_test_utils.h File Reference

Common Tesseract unit test utilities. More...

#include <tesseract/common/macros.h>
#include <gtest/gtest.h>
#include <tesseract/common/serialization.h>
#include <tesseract/common/any_poly.h>
#include <tesseract/common/utils.h>

Typedefs

template<typename SerializableType >
using tesseract::common::TestSerializationCompareFn = std::function< bool(const SerializableType &, const SerializableType &)>
 

Functions

template<typename SerializableType >
bool tesseract::common::testSerializationCompareEqual (const SerializableType &a, const SerializableType &b)
 
template<typename SerializableType >
bool tesseract::common::testSerializationComparePtrEqual (const SerializableType &a, const SerializableType &b)
 
template<typename SerializableType >
void tesseract::common::testSerialization (const SerializableType &object, const std::string &typename_string, TestSerializationCompareFn< SerializableType > compare=testSerializationCompareEqual< SerializableType >)
 Tests serialization for a serializable type.
 
template<typename SerializableTypeBase , typename SerializableTypeDerived >
void tesseract::common::testSerializationDerivedClass (const std::shared_ptr< SerializableTypeBase > &object, const std::string &typename_string)
 Tests serialization for a serializable derived type.
 
template<typename SerializableTypeStored >
void tesseract::common::testSerializationAnyPoly (const tesseract::common::AnyPoly &object, const std::string &typename_string, TestSerializationCompareFn< SerializableTypeStored > compare=testSerializationCompareEqual< SerializableTypeStored >)
 Tests serialization for a serializable any poly type.
 

Detailed Description

Common Tesseract unit test utilities.

Author
Levi Armstrong
Matthew Powelson
Date
March 16, 2022
License
Software License Agreement (Apache License)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ testSerialization()

template<typename SerializableType >
void tesseract::common::testSerialization ( const SerializableType &  object,
const std::string &  typename_string,
TestSerializationCompareFn< SerializableType >  compare = testSerializationCompareEqual<SerializableType> 
)

Tests serialization for a serializable type.

Serializes the type to XML file, binary file, and XML string. It then deserializes it and calls the equality operator on the results

Parameters
objectObject to be serialized
typename_stringPrefix used for filepaths. Serialized files are put in /tmp/<typename_string>.<extension>

◆ testSerializationDerivedClass()

template<typename SerializableTypeBase , typename SerializableTypeDerived >
void tesseract::common::testSerializationDerivedClass ( const std::shared_ptr< SerializableTypeBase > &  object,
const std::string &  typename_string 
)

Tests serialization for a serializable derived type.

Serializes the type to XML file, binary file, and XML string using the base type. It then deserializes it, casts it to the derived type, and calls the equality operator on the results

Parameters
objectBase class pointer to the object to be serialized
typename_stringPrefix used for filepaths. Serialized files are put in /tmp/<typename_string>.<extension>

◆ testSerializationAnyPoly()

template<typename SerializableTypeStored >
void tesseract::common::testSerializationAnyPoly ( const tesseract::common::AnyPoly object,
const std::string &  typename_string,
TestSerializationCompareFn< SerializableTypeStored >  compare = testSerializationCompareEqual<SerializableTypeStored> 
)

Tests serialization for a serializable any poly type.

Serializes the type to XML file, binary file, and XML string using the base type. It then deserializes it, casts it to the derived type, and calls the equality operator on the results

Parameters
objectBase class pointer to the object to be serialized
typename_stringPrefix used for filepaths. Serialized files are put in /tmp/<typename_string>.<extension>