Main MRPT website > C++ reference for MRPT 1.9.9
maps/src/maps/serializations_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-2018, 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/maps.h>
12 
13 #include <mrpt/io/CMemoryStream.h>
15 #include <gtest/gtest.h>
16 #include <CTraitsTest.h>
17 
18 using namespace mrpt;
19 using namespace mrpt::maps;
20 using namespace mrpt::obs;
21 using namespace mrpt::io;
22 using namespace mrpt::serialization;
23 using namespace std;
24 
25 #define TEST_CLASS_MOVE_COPY_CTORS(_classname) \
26  template class mrpt::CTraitsTest<_classname>
27 
41 
42 // Create a set of classes, then serialize and deserialize to test possible
43 // bugs:
44 TEST(SerializeTestMaps, WriteReadToMem)
45 {
60 
61  for (size_t i = 0; i < sizeof(lstClasses) / sizeof(lstClasses[0]); i++)
62  {
63  try
64  {
65  CMemoryStream buf;
66  auto arch = mrpt::serialization::archiveFrom(buf);
67  {
68  CSerializable* o =
69  static_cast<CSerializable*>(lstClasses[i]->createObject());
70  arch << *o;
71  delete o;
72  }
73 
74  buf.Seek(0);
75  std::variant<
76  CBeacon,
77  CBeaconMap,
87  COctoMap,
88  CColouredOctoMap> recons;
89  arch >> recons;
90  }
91  catch (std::exception& e)
92  {
93  GTEST_FAIL() << "Exception during serialization test for class '"
94  << lstClasses[i]->className << "':\n"
95  << e.what() << endl;
96  }
97  }
98 }
mrpt::io::CMemoryStream::Seek
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource.
Definition: CMemoryStream.cpp:120
mrpt::maps::CGasConcentrationGridMap2D
CGasConcentrationGridMap2D represents a PDF of gas concentrations over a 2D area.
Definition: CGasConcentrationGridMap2D.h:35
mrpt::maps::CColouredPointsMap
A map of 2D/3D points with individual colours (RGB).
Definition: CColouredPointsMap.h:29
mrpt::rtti::TRuntimeClassId
A structure that holds runtime class type information.
Definition: CObject.h:30
mrpt::io
Definition: img/CImage.h:22
mrpt::maps::CWeightedPointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
Definition: CWeightedPointsMap.h:30
CMemoryStream.h
mrpt::rtti::TRuntimeClassId::className
const char * className
Definition: CObject.h:33
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::maps::CWirelessPowerGridMap2D
CWirelessPowerGridMap2D represents a PDF of wifi concentrations over a 2D area.
Definition: CWirelessPowerGridMap2D.h:35
mrpt::maps::CHeightGridMap2D
Digital Elevation Model (DEM), a mesh or grid representation of a surface which keeps the estimated h...
Definition: CHeightGridMap2D.h:63
maps.h
mrpt::maps::CSimplePointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
Definition: CSimplePointsMap.h:31
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::rtti::TRuntimeClassId::createObject
mrpt::rtti::CObject * createObject() const
Definition: CObject.cpp:79
mrpt::io::CMemoryStream
This CStream derived class allow using a memory buffer as a CStream.
Definition: io/CMemoryStream.h:26
mrpt::serialization
Definition: aligned_serialization.h:14
mrpt::maps::CColouredOctoMap
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: CColouredOctoMap.h:31
mrpt::maps::COctoMap
A three-dimensional probabilistic occupancy grid, implemented as an octo-tree with the "octomap" C++ ...
Definition: COctoMap.h:35
mrpt::serialization::archiveFrom
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
Definition: CArchive.h:561
CLASS_ID
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:85
mrpt::maps::CBeaconMap
A class for storing a map of 3D probabilistic beacons, using a Montecarlo, Gaussian,...
Definition: CBeaconMap.h:46
mrpt::maps::CRandomFieldGridMap3D
CRandomFieldGridMap3D represents a 3D regular grid where each voxel is associated one real-valued pro...
Definition: CRandomFieldGridMap3D.h:78
mrpt::maps::CReflectivityGridMap2D
A 2D grid map representing the reflectivity of the environment (for example, measured with an IR prox...
Definition: CReflectivityGridMap2D.h:41
mrpt::maps::CBeacon
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions.
Definition: CBeacon.h:38
lstClasses
const mrpt::rtti::TRuntimeClassId * lstClasses[]
Definition: CLogFileRecord_unittest.cpp:28
mrpt::maps::COccupancyGridMap2D
A class for storing an occupancy grid map.
Definition: COccupancyGridMap2D.h:62
mrpt::maps
Definition: CBeacon.h:24
CArchive.h
TEST
TEST(SerializeTestMaps, WriteReadToMem)
Definition: maps/src/maps/serializations_unittest.cpp:44
TEST_CLASS_MOVE_COPY_CTORS
#define TEST_CLASS_MOVE_COPY_CTORS(_classname)
Definition: maps/src/maps/serializations_unittest.cpp:25



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST