Main MRPT website > C++ reference for MRPT 1.5.6
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 { namespace utils {
23  }
24 }
25 
26 
27 // Create a set of classes, then serialize and deserialize to test possible bugs:
28 TEST(SerializeTestOpenGL, WriteReadToMem)
29 {
31  CLASS_ID( CAxis ),
32  CLASS_ID( CBox ),
33  CLASS_ID( CFrustum ),
34  CLASS_ID( CDisk ),
36 #if MRPT_HAS_OPENCV // These classes need CImage serialization
37  CLASS_ID( CMesh ),
39 #endif
45  CLASS_ID( CSphere ),
49  CLASS_ID( CArrow ),
50  CLASS_ID( CCamera ),
56  CLASS_ID( CText ),
57  CLASS_ID( CText3D ),
62  };
63 
64  for (size_t i=0;i<sizeof(lstClasses)/sizeof(lstClasses[0]);i++)
65  {
66  try
67  {
68  CMemoryStream buf;
69  {
70  CSerializable* o = static_cast<CSerializable*>(lstClasses[i]->createObject());
71  buf << *o;
72  delete o;
73  }
74 
75  CSerializablePtr recons;
76  buf.Seek(0);
77  buf >> recons;
78  }
79  catch(std::exception &e)
80  {
81  GTEST_FAIL() <<
82  "Exception during serialization test for class '"<< lstClasses[i]->className <<"':\n" << e.what() << endl;
83  }
84  }
85 }
A 2D text (bitmap rendering): it always "faces the observer" despite it&#39;s at some 3D location...
Definition: CText.h:39
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
Definition: CBox.h:37
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
std::string MRPT_GLOBAL_UNITTEST_SRC_DIR
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:35
A set of object, which are referenced to the coordinates framework established in this object...
Definition: CSetOfObjects.h:32
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
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:35
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:34
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
mrpt::utils::CObject * createObject() const
Definition: CObject.cpp:89
This CStream derived class allow using a memory buffer as a CStream.
Definition: CMemoryStream.h:26
A planar disk in the XY plane.
Definition: CDisk.h:34
A cylinder or cone whose base lies in the XY plane.
Definition: CCylinder.h:30
GLsizei const GLchar ** string
Definition: glext.h:3919
#define CLASS_ID(class_name)
Access to runtime class ID for a defined class name.
Definition: CObject.h:92
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A line segment.
Definition: CSimpleLine.h:27
This object represents any figure obtained by extruding any profile along a given axis...
A solid or wire-frame sphere.
Definition: CSphere.h:34
TEST(SerializeTestOpenGL, WriteReadToMem)
Draw a 3D world axis, with coordinate marks at some regular interval.
Definition: CAxis.h:34
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.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
Definition: COpenGLScene.h:49
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
Definition: CFrustum.h:47
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...
A 3D arrow.
Definition: CArrow.h:34
A set of colored triangles.
A structure that holds runtime class type information.
Definition: CObject.h:46
A planar (XY) grid where each cell has an associated height and, optionally, a texture map...
Definition: CMesh.h:40
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:43
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:31
const char * className
Definition: CObject.h:48
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:46



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019