Classes | Namespaces | Defines | Functions
serialization.cpp File Reference
#include <gtest/gtest.h>
#include <ros/static_assert.h>
#include <std_msgs/Header.h>
#include "test_roscpp_serialization/helpers.h"
Include dependency graph for serialization.cpp:

Go to the source code of this file.

Classes

struct  AllInOneSerializer
struct  FixedSizeNonSimple
struct  FixedSizeSimple
struct  ros::message_traits::HasHeader< WithHeader >
struct  ros::message_traits::IsFixedSize< FixedSizeNonSimple >
struct  ros::message_traits::IsFixedSize< FixedSizeSimple >
struct  ros::message_traits::IsSimple< FixedSizeSimple >
struct  ros::serialization::Serializer< AllInOneSerializer >
struct  ros::serialization::Serializer< FixedSizeNonSimple >
struct  ros::serialization::Serializer< FixedSizeSimple >
struct  ros::serialization::Serializer< VariableSize >
struct  VariableSize
struct  WithHeader
struct  WithoutHeader

Namespaces

namespace  ros
namespace  ros::message_traits
namespace  ros::serialization

Defines

#define PRIMITIVE_FIXED_LENGTH_ARRAY_TEST(Type, Start, Increment)
#define PRIMITIVE_SERIALIZATION_TEST(Type, SerInit, DeserInit)
#define PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST(Type, Start, Increment)

Functions

int main (int argc, char **argv)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (uint8_t, 65, 1)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (int8_t, 65, 1)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (uint16_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (int16_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (uint32_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (int32_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (uint64_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (int64_t, 0, 100)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (float, 0.0f, 100.0f)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (double, 0.0, 100.0)
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (Time, Time(), Duration(100))
 PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (Duration, Duration(), Duration(100))
 PRIMITIVE_SERIALIZATION_TEST (uint8_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (int8_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (uint16_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (int16_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (uint32_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (int32_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (uint64_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (int64_t,(5),(0))
 PRIMITIVE_SERIALIZATION_TEST (float,(5.0f),(0.0f))
 PRIMITIVE_SERIALIZATION_TEST (double,(5.0),(0.0))
 PRIMITIVE_SERIALIZATION_TEST (Time,(500, 10000),(0, 0))
 PRIMITIVE_SERIALIZATION_TEST (Duration,(500, 10000),(0, 0))
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (uint8_t, 65, 1)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (int8_t, 65, 1)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (uint16_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (int16_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (uint32_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (int32_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (uint64_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (int64_t, 0, 100)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (float, 0.0f, 100.0f)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (double, 0.0, 100.0)
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (Time, Time(), Duration(100))
 PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (Duration, Duration(), Duration(100))
 ROS_STATIC_ASSERT (sizeof(ros::Time)==8)
 ROS_STATIC_ASSERT (sizeof(ros::Duration)==8)
 TEST (Serialization, string)
 TEST (Serialization, variableLengthArray_string)
 TEST (Serialization, fixedLengthArray_string)
 TEST (Serialization, fixedSizeSimple_vector)
 TEST (Serialization, fixedSizeSimple_array)
 TEST (Serialization, fixedSizeNonSimple_vector)
 TEST (Serialization, fixedSizeNonSimple_array)
 TEST (Serialization, variableSize_vector)
 TEST (Serialization, variableSize_array)
 TEST (Serialization, allInOne)
 TEST (MessageTraits, headers)
 TEST (Serialization, bufferOverrun)
 TEST (Serialization, streamOperators)

Define Documentation

#define PRIMITIVE_FIXED_LENGTH_ARRAY_TEST (   Type,
  Start,
  Increment 
)
Value:
TEST(Serialization, fixedLengthArray_##Type) \
  { \
    boost::array<Type, 8> ser_val, deser_val; \
    Type val = Start; \
    for (uint32_t i = 0; i < 8; ++i) \
    { \
      ser_val[i] = val; \
      val = val + Increment; \
    } \
    \
    Array b = serializeAndDeserialize(ser_val, deser_val); \
    EXPECT_TRUE(ser_val == deser_val); \
    \
    for(size_t i = 0; i < ser_val.size(); ++i) \
    { \
      Type* ptr = ((Type*)b.get()) + i; \
      EXPECT_EQ(*ptr, ser_val[i]); \
    } \
  }

Definition at line 110 of file serialization.cpp.

#define PRIMITIVE_SERIALIZATION_TEST (   Type,
  SerInit,
  DeserInit 
)
Value:
TEST(Serialization, Type) \
  { \
    Type ser_val SerInit; \
    Type deser_val DeserInit; \
    Array b = serializeAndDeserialize(ser_val, deser_val); \
    EXPECT_EQ(*(Type*)b.get(), ser_val); \
    EXPECT_EQ(ser_val, deser_val); \
  }

Definition at line 52 of file serialization.cpp.

#define PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST (   Type,
  Start,
  Increment 
)
Value:
TEST(Serialization, variableLengthArray_##Type) \
  { \
    std::vector<Type> ser_val, deser_val; \
    Type val = Start; \
    for (uint32_t i = 0; i < 8; ++i) \
    { \
      ser_val.push_back(val); \
      val = val + Increment; \
    } \
    \
    Array b = serializeAndDeserialize(ser_val, deser_val); \
    EXPECT_TRUE(ser_val == deser_val); \
    \
    EXPECT_EQ(*(uint32_t*)b.get(), (uint32_t)ser_val.size()); \
    for(size_t i = 0; i < ser_val.size(); ++i) \
    { \
      Type* ptr = ((Type*)(b.get() + 4)) + i; \
      EXPECT_EQ(*ptr, ser_val[i]); \
    } \
  }

Definition at line 75 of file serialization.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 470 of file serialization.cpp.

PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( uint8_t  ,
65  ,
 
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( int8_t  ,
65  ,
 
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( uint16_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( int16_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( uint32_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( int32_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( uint64_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( int64_t  ,
,
100   
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( float  ,
0.  0f,
100.  0f 
)
PRIMITIVE_FIXED_LENGTH_ARRAY_TEST ( double  ,
0.  0,
100.  0 
)
PRIMITIVE_SERIALIZATION_TEST ( uint8_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( int8_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( uint16_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( int16_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( uint32_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( int32_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( uint64_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( int64_t  ,
(5)  ,
(0)   
)
PRIMITIVE_SERIALIZATION_TEST ( float  ,
(5.0f)  ,
(0.0f)   
)
PRIMITIVE_SERIALIZATION_TEST ( double  ,
(5.0)  ,
(0.0)   
)
PRIMITIVE_SERIALIZATION_TEST ( Time  ,
(500, 10000)  ,
(0, 0)   
)
PRIMITIVE_SERIALIZATION_TEST ( Duration  ,
(500, 10000)  ,
(0, 0)   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( uint8_t  ,
65  ,
 
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( int8_t  ,
65  ,
 
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( uint16_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( int16_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( uint32_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( int32_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( uint64_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( int64_t  ,
,
100   
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( float  ,
0.  0f,
100.  0f 
)
PRIMITIVE_VARIABLE_LENGTH_ARRAY_TEST ( double  ,
0.  0,
100.  0 
)
ROS_STATIC_ASSERT ( sizeof(ros::Time = =8)
ROS_STATIC_ASSERT ( sizeof(ros::Duration = =8)
TEST ( Serialization  ,
string   
)

Definition at line 144 of file serialization.cpp.

TEST ( Serialization  ,
variableLengthArray_string   
)

Definition at line 155 of file serialization.cpp.

TEST ( Serialization  ,
fixedLengthArray_string   
)

Definition at line 167 of file serialization.cpp.

TEST ( Serialization  ,
fixedSizeSimple_vector   
)

Definition at line 229 of file serialization.cpp.

TEST ( Serialization  ,
fixedSizeSimple_array   
)

Definition at line 253 of file serialization.cpp.

TEST ( Serialization  ,
fixedSizeNonSimple_vector   
)

Definition at line 295 of file serialization.cpp.

TEST ( Serialization  ,
fixedSizeNonSimple_array   
)

Definition at line 305 of file serialization.cpp.

TEST ( Serialization  ,
variableSize_vector   
)

Definition at line 340 of file serialization.cpp.

TEST ( Serialization  ,
variableSize_array   
)

Definition at line 350 of file serialization.cpp.

TEST ( Serialization  ,
allInOne   
)

Definition at line 382 of file serialization.cpp.

TEST ( MessageTraits  ,
headers   
)

Definition at line 414 of file serialization.cpp.

TEST ( Serialization  ,
bufferOverrun   
)

Definition at line 441 of file serialization.cpp.

TEST ( Serialization  ,
streamOperators   
)

Definition at line 458 of file serialization.cpp.



test_roscpp_serialization
Author(s): Josh Faust
autogenerated on Sat Dec 28 2013 17:35:47