26 #include <gtsam/base/serialization.h> 28 #include <boost/serialization/serialization.hpp> 32 const bool verbose =
false;
35 namespace serializationTestHelpers {
45 void roundtrip(
const T& input, T& output) {
47 std::string serialized = serialize(input);
48 if (verbose) std::cout << serialized << std::endl << std::endl;
50 deserialize(serialized, output);
55 bool equality(
const T& input = T()) {
56 T output = create<T>();
57 roundtrip<T>(input,output);
63 bool equalsObj(
const T& input = T()) {
64 T output = create<T>();
65 roundtrip<T>(input,output);
71 bool equalsDereferenced(
const T& input) {
72 T output = create<T>();
73 roundtrip<T>(input,output);
74 return input->equals(*output);
79 void roundtripXML(
const T& input, T& output) {
81 std::string serialized = serializeXML<T>(input);
82 if (verbose) std::cout << serialized << std::endl << std::endl;
85 deserializeXML(serialized, output);
90 bool equalityXML(
const T& input = T()) {
91 T output = create<T>();
92 roundtripXML<T>(input,output);
98 bool equalsXML(
const T& input = T()) {
99 T output = create<T>();
100 roundtripXML<T>(input,output);
106 bool equalsDereferencedXML(
const T& input = T()) {
107 T output = create<T>();
108 roundtripXML<T>(input,output);
109 return input->equals(*output);
114 void roundtripBinary(
const T& input, T& output) {
116 std::string serialized = serializeBinary<T>(input);
117 if (verbose) std::cout << serialized << std::endl << std::endl;
120 deserializeBinary(serialized, output);
125 bool equalityBinary(
const T& input = T()) {
126 T output = create<T>();
127 roundtripBinary<T>(input,output);
128 return input==output;
133 bool equalsBinary(
const T& input = T()) {
134 T output = create<T>();
135 roundtripBinary<T>(input,output);
141 bool equalsDereferencedBinary(
const T& input = T()) {
142 T output = create<T>();
143 roundtripBinary<T>(input,output);
144 return input->equals(*output);
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
equals with an tolerance, prints out message if unequal
Definition: Matrix.cpp:42
Global functions in a separate testing namespace.
Definition: chartTesting.h:28