MRPT  1.9.9
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
11 #include <mrpt/opengl.h>
12 
13 #include <mrpt/io/CMemoryStream.h>
15 
16 #include <gtest/gtest.h>
17 
18 using namespace mrpt;
19 using namespace mrpt::opengl;
20 using namespace mrpt::serialization;
21 using namespace std;
22 
23 // Create a set of classes, then serialize and deserialize to test possible
24 // bugs:
25 TEST(SerializeTestOpenGL, WriteReadToMem)
26 {
28  CLASS_ID(CAxis),
29  CLASS_ID(CBox),
31  CLASS_ID(CDisk),
33 #if MRPT_HAS_OPENCV // These classes need CImage serialization
34  CLASS_ID(CMesh),
36 #endif
53  CLASS_ID(CText),
59  };
60 
61  for (size_t i = 0; i < sizeof(lstClasses) / sizeof(lstClasses[0]); i++)
62  {
63  try
64  {
66  {
67  CSerializable* o =
68  static_cast<CSerializable*>(lstClasses[i]->createObject());
70  delete o;
71  }
72 
73  CSerializable::Ptr recons;
74  buf.Seek(0);
75  mrpt::serialization::archiveFrom(buf) >> recons;
76  }
77  catch (std::exception& e)
78  {
79  GTEST_FAIL() << "Exception during serialization test for class '"
80  << lstClasses[i]->className << "':\n"
81  << e.what() << endl;
82  }
83  }
84 }
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:36
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:40
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:30
A set of object, which are referenced to the coordinates framework established in this object...
Definition: CSetOfObjects.h:26
A cloud of points, each one with an individual colour (R,G,B).
A structure that holds runtime class type information.
Definition: CObject.h:30
An especial "ellipsoid" in 3D computed as the uncertainty iso-surfaces of a (inv_range,yaw,pitch) variable.
STL namespace.
An especial "ellipsoid" in 3D computed as the uncertainty iso-surfaces of a (inv_range,yaw) variable.
A 2D plane in the XY plane with a texture image.
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:30
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
This class represents arbitrary polyhedra.
Definition: CPolyhedron.h:44
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT&#39;s CStream, std::istream, std::ostream, std::stringstream
Definition: CArchive.h:555
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:84
const char * className
Definition: CObject.h:33
This CStream derived class allow using a memory buffer as a CStream.
A planar disk in the XY plane.
Definition: CDisk.h:31
A cylinder or cone whose base lies in the XY plane.
Definition: CCylinder.h:30
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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A line segment.
Definition: CSimpleLine.h:20
This object represents any figure obtained by extruding any profile along a given axis...
A solid or wire-frame sphere.
Definition: CSphere.h:29
TEST(SerializeTestOpenGL, WriteReadToMem)
Draw a 3D world axis, with coordinate marks at some regular interval.
Definition: CAxis.h:29
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:43
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
Definition: COpenGLScene.h:59
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
Definition: CFrustum.h:52
const mrpt::rtti::TRuntimeClassId * lstClasses[]
A 3D arrow.
Definition: CArrow.h:29
A set of colored triangles.
mrpt::rtti::CObject * createObject() const
Definition: CObject.cpp:79
A planar (XY) grid where each cell has an associated height and, optionally, a texture map...
Definition: CMesh.h:37
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:45
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:28
A set of independent lines (or segments), one line with its own start and end positions (X...
Definition: CSetOfLines.h:31
An especial "ellipsoid" in 2D computed as the uncertainty iso-surfaces of a (range,bearing) variable.
A cloud of points, all with the same color or each depending on its value along a particular coordina...
Definition: CPointCloud.h:43



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020