Main MRPT website > C++ reference for MRPT 1.9.9
CSerializable_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #define MRPT_NO_WARN_BIG_HDR // Yes, we really want to include all classes.
11 #include <mrpt/obs.h>
12 
14 #include <gtest/gtest.h>
15 #include <mrpt/utils/CTraitsTest.h>
16 
17 using namespace mrpt;
18 using namespace mrpt::obs;
19 using namespace mrpt::utils;
20 using namespace mrpt::math;
21 using namespace std;
22 
23 #define TEST_CLASS_MOVE_COPY_CTORS(_classname) \
24  template class mrpt::utils::CTraitsTest<_classname>
25 
41 #if MRPT_HAS_OPENCV // These classes need CImage serialization
44 #endif
51 
52 // Defined in tests/test_main.cpp
53 namespace mrpt
54 {
55 namespace utils
56 {
58 }
59 }
60 
62  // Observations:
71 #if MRPT_HAS_OPENCV // These classes need CImage serialization
73 #endif
76  // Actions:
78 
79 // Create a set of classes, then serialize and deserialize to test possible
80 // bugs:
81 TEST(SerializeTestObs, WriteReadToMem)
82 {
83  for (size_t i = 0; i < sizeof(lstClasses) / sizeof(lstClasses[0]); i++)
84  {
85  try
86  {
87  CMemoryStream buf;
88  {
89  CSerializable* o =
90  static_cast<CSerializable*>(lstClasses[i]->createObject());
91  buf << *o;
92  delete o;
93  }
94 
95  CSerializable::Ptr recons;
96  buf.Seek(0);
97  buf >> recons;
98  }
99  catch (std::exception& e)
100  {
101  GTEST_FAIL() << "Exception during serialization test for class '"
102  << lstClasses[i]->className << "':\n"
103  << e.what() << endl;
104  }
105  }
106 }
107 
108 // Also try to convert them to octect vectors:
109 TEST(SerializeTestObs, WriteReadToOctectVectors)
110 {
111  for (size_t i = 0; i < sizeof(lstClasses) / sizeof(lstClasses[0]); i++)
112  {
113  try
114  {
115  mrpt::vector_byte buf;
116  {
117  CSerializable* o =
118  static_cast<CSerializable*>(lstClasses[i]->createObject());
120  delete o;
121  }
122 
123  CSerializable::Ptr recons;
125  }
126  catch (std::exception& e)
127  {
128  GTEST_FAIL() << "Exception during serialization test for class '"
129  << lstClasses[i]->className << "':\n"
130  << e.what() << endl;
131  }
132  }
133 }
This "observation" is actually a placeholder for a text block with comments or additional parameters ...
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
This represents a measurement of the batteries on the robot.
Declares a class derived from "CObservation" that encapsules an omnidirectional RGBD measurement from...
Declares a class derived from "CObservation" that encapsules a single range measurement, and associated parameters.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
A CObservation-derived class for RAW DATA (and optionally, point cloud) of scans from 3D Velodyne LID...
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
std::vector< uint8_t > vector_byte
Definition: types_simple.h:27
TEST(SerializeTestObs, WriteReadToMem)
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
This class stores a message from a CAN BUS with the protocol J1939.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
Declares a class derived from "CObservation" that represents one (or more) range measurements to labe...
Declares a class derived from "CObservation" that encapsules a single short-range reflectivity measur...
STL namespace.
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation, raw gyroscope and accelerometer values), altimeters or magnetometers.
#define TEST_CLASS_MOVE_COPY_CTORS(_classname)
void OctetVectorToObject(const vector_byte &in_data, CSerializable::Ptr &obj)
Converts back (de-serializes) a sequence of binary data into a MRPT object, without prior information...
Represents a probabilistic 3D (6D) movement.
Represents a probabilistic 2D movement of the robot mobile base.
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
mrpt::utils::CObject * createObject() const
Definition: CObject.cpp:93
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:85
void ObjectToOctetVector(const CSerializable *o, vector_byte &out_vector)
Converts (serializes) an MRPT object into an array of bytes.
This CStream derived class allow using a memory buffer as a CStream.
Definition: CMemoryStream.h:27
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
This namespace contains representation of robot actions and observations.
Declares a class derived from "CObservation" that represents a set of readings from gas sensors...
GLsizei const GLchar ** string
Definition: glext.h:4101
Store raw data from a Data Acquisition (DAQ) device, such that input or output analog and digital cha...
This represents a measurement of the wireless strength perceived by the robot.
std::shared_ptr< CSerializable > Ptr
Definition: CSerializable.h:47
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
An observation of one or more "features" or "objects", possibly identified with a unique ID...
This observation represents a number of range-bearing value pairs, each one for a detected landmark...
const mrpt::utils::TRuntimeClassId * lstClasses[]
This represents one or more RFID tags observed by a receiver.
A structure that holds runtime class type information.
Definition: CObject.h:31
An observation of the current (cumulative) odometry for a wheeled robot.
const char * className
Definition: CObject.h:34
This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receive...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019