Main MRPT website > C++ reference for 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-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
11 #include <mrpt/opengl.h>
12 
13 #include <gtest/gtest.h>
14 
15 using namespace mrpt;
16 using namespace mrpt::opengl;
17 using namespace mrpt::utils;
18 using namespace std;
19 
20 // Defined in tests/test_main.cpp
21 namespace mrpt
22 {
23 namespace utils
24 {
26 }
27 }
28 
29 // Create a set of classes, then serialize and deserialize to test possible
30 // bugs:
31 TEST(SerializeTestOpenGL, WriteReadToMem)
32 {
34  CLASS_ID(CAxis),
35  CLASS_ID(CBox),
37  CLASS_ID(CDisk),
39 #if MRPT_HAS_OPENCV // These classes need CImage serialization
40  CLASS_ID(CMesh),
42 #endif
59  CLASS_ID(CText),
65  };
66 
67  for (size_t i = 0; i < sizeof(lstClasses) / sizeof(lstClasses[0]); i++)
68  {
69  try
70  {
71  CMemoryStream buf;
72  {
73  CSerializable* o =
74  static_cast<CSerializable*>(lstClasses[i]->createObject());
75  buf << *o;
76  delete o;
77  }
78 
79  CSerializable::Ptr recons;
80  buf.Seek(0);
81  buf >> recons;
82  }
83  catch (std::exception& e)
84  {
85  GTEST_FAIL() << "Exception during serialization test for class '"
86  << lstClasses[i]->className << "':\n"
87  << e.what() << endl;
88  }
89  }
90 }
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:38
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:42
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:32
A set of object, which are referenced to the coordinates framework established in this object...
Definition: CSetOfObjects.h:30
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...
A cloud of points, each one with an individual colour (R,G,B).
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:32
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
const mrpt::utils::TRuntimeClassId * lstClasses[]
This class represents arbitrary polyhedra.
Definition: CPolyhedron.h:44
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
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
This CStream derived class allow using a memory buffer as a CStream.
Definition: CMemoryStream.h:27
A planar disk in the XY plane.
Definition: CDisk.h:33
A cylinder or cone whose base lies in the XY plane.
Definition: CCylinder.h:32
GLsizei const GLchar ** string
Definition: glext.h:4101
std::shared_ptr< CSerializable > Ptr
Definition: CSerializable.h:47
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A line segment.
Definition: CSimpleLine.h:22
This object represents any figure obtained by extruding any profile along a given axis...
A solid or wire-frame sphere.
Definition: CSphere.h:31
TEST(SerializeTestOpenGL, WriteReadToMem)
Draw a 3D world axis, with coordinate marks at some regular interval.
Definition: CAxis.h:31
A 3D text (rendered with OpenGL primitives), with selectable font face and drawing style...
Definition: CText3D.h:45
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:60
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
Definition: CFrustum.h:54
A 3D arrow.
Definition: CArrow.h:31
A set of colored triangles.
A structure that holds runtime class type information.
Definition: CObject.h:31
A planar (XY) grid where each cell has an associated height and, optionally, a texture map...
Definition: CMesh.h:39
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:47
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:30
const char * className
Definition: CObject.h:34
A set of independent lines (or segments), one line with its own start and end positions (X...
Definition: CSetOfLines.h:35
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:47



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