20 #include <gtest/gtest.h> 29 namespace mrpt {
namespace utils {
36 TEST(SerializeTestBase, LoadDemoFile)
61 R.v9 =
"an example test";
69 cerr <<
"WARNING: Skipping test due to missing file: " << fil <<
"\n";
74 gg >> L.v1 >> L.v2 >> L.v3 >> L.v4 >> L.v5 >> L.v6 >> L.v7 >> L.v8 >> L.v9;
76 EXPECT_EQ(
R.v1,L.v1 );
77 EXPECT_EQ(
R.v2,L.v2 );
78 EXPECT_EQ(
R.v3,L.v3 );
79 EXPECT_EQ(
R.v4,L.v4 );
80 EXPECT_EQ(
R.v5,L.v5 );
81 EXPECT_EQ(
R.v6,L.v6 );
82 EXPECT_EQ(
R.v7,L.v7 );
83 EXPECT_EQ(
R.v8,L.v8 );
84 EXPECT_EQ(
R.v9,L.v9 );
103 TEST(SerializeTestBase, WriteReadToMem)
116 CSerializablePtr recons;
120 catch(std::exception &e)
123 "Exception during serialization test for class '"<<
lstClasses[i]->
className <<
"':\n" << e.what() << endl;
129 TEST(SerializeTestBase, CopyOperator)
141 catch(std::exception &e)
144 "Exception during copy operator test for class '"<<
lstClasses[i]->
className <<
"':\n" << e.what() << endl;
164 catch(std::exception &e)
167 "Exception:\n" << e.what() << endl;
173 TEST(SerializeTestBase, STL_serialization)
181 std::vector<double>
a,
b;
183 for (
size_t i=0;i<
a.size();i++)
a[i]=50-i;
185 buf <<
a; buf.
Seek(0); buf >>
b;
193 std::list<std::map<double,std::set<std::string> > >
a,
b;
198 for (
size_t i=0;i<N;i++)
200 std::map<double,std::set<std::string> > d;
202 for (
size_t j=0;j<M;j++)
206 for (
size_t k=0;k<L;k++)
213 buf <<
a; buf.
Seek(0); buf >>
b;
217 catch(std::exception &e)
220 "Exception:\n" << e.what() << endl;
226 TEST(SerializeTestBase, CastSmartPointers)
231 CPose2DPtr p1 = CPose2D::Create();
233 mrpt::utils::CSerializablePtr p2 = p1;
235 mrpt::utils::CSerializablePtr p3 = p2;
237 mrpt::utils::CSerializablePtr p4 = p1;
double drawUniform(const double Min, const double Max)
Generate a uniformly distributed pseudo-random number using the MT19937 algorithm, scaled to the selected range.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
unsigned __int16 uint16_t
The virtual base class which provides a unified interface for all persistent objects in MRPT...
bool BASE_IMPEXP fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
A thred-safe pseudo random number generator, based on an internal MT19937 randomness generator...
double drawGaussian1D_normalized(double *likelihood=NULL)
Generate a normalized (mean=0, std=1) normally distributed sample.
const mrpt::utils::TRuntimeClassId * lstClasses[]
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
Structure to hold the parameters of a pinhole stereo camera model.
This base provides a set of functions for maths stuff.
mrpt::utils::CObject * createObject() const
This CStream derived class allow using a memory buffer as a CStream.
A STL container (as wrapper) for arrays of constant size defined at compile time. ...
TEST(SerializeTestBase, LoadDemoFile)
GLfloat GLfloat GLfloat GLfloat v3
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
A class used to store a 2D point.
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define CLASS_ID(class_name)
Access to runtime class ID for a defined class name.
unsigned __int64 uint64_t
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) MRPT_OVERRIDE
Introduces a pure virtual method for moving to a specified position in the streamed resource...
GLfloat GLfloat GLfloat v2
A structure that holds runtime class type information.
unsigned __int32 uint32_t
GLubyte GLubyte GLubyte a