measurement_report_config_test.cpp
Go to the documentation of this file.
00001 
00027 #include <gtest/gtest.h>
00028 #include <boost/asio.hpp>
00029 
00030 #include "omron_os32c_driver/measurement_report_config.h"
00031 #include "odva_ethernetip/serialization/serializable_buffer.h"
00032 #include "odva_ethernetip/serialization/buffer_writer.h"
00033 #include "odva_ethernetip/serialization/buffer_reader.h"
00034 
00035 using namespace boost::asio;
00036 using namespace omron_os32c_driver;
00037 using namespace eip;
00038 using namespace eip::serialization;
00039 using namespace boost::asio;
00040 
00041 class MeasurementReportConfigTest : public :: testing :: Test
00042 {
00043 
00044 };
00045 
00046 TEST_F(MeasurementReportConfigTest, test_deserialize)
00047 {
00048   EIP_BYTE d[] = {
00049     0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00,
00050     0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00051     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00052     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00053     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00054     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00055     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00056     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
00057     0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00058     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00059     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00060     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00061     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00062     0x00, 0x00, 0x00, 0x00, 0x00, 0x00
00063   };
00064 
00065   BufferReader reader(buffer(d));
00066   MeasurementReportConfig mrc;
00067   mrc.deserialize(reader);
00068   EXPECT_EQ(sizeof(d), reader.getByteCount());
00069   EXPECT_EQ(sizeof(d), mrc.getLength());
00070   EXPECT_EQ(0x0001, mrc.sequence_num);
00071   EXPECT_EQ(0x00000003, mrc.trigger);
00072   EXPECT_EQ(1, mrc.range_report_format);
00073   EXPECT_EQ(2, mrc.reflectivity_report_format);
00074   for (size_t i = 0; i < 41; ++i)
00075   {
00076     EXPECT_EQ(0, mrc.beam_selection_mask[i]);
00077   }
00078   EXPECT_EQ(0xFF, mrc.beam_selection_mask[41]);
00079   EXPECT_EQ(0xFF, mrc.beam_selection_mask[42]);
00080   EXPECT_EQ(0x0F, mrc.beam_selection_mask[43]);
00081   for (size_t i = 44; i < 88; ++i)
00082   {
00083     EXPECT_EQ(0, mrc.beam_selection_mask[i]);
00084   }
00085 }
00086 
00087 TEST_F(MeasurementReportConfigTest, test_serialize)
00088 {
00089   MeasurementReportConfig mrc;
00090   mrc.sequence_num = 0x0001;
00091   mrc.trigger = 0x00000003;
00092   mrc.range_report_format = 1;
00093   mrc.reflectivity_report_format = 2;
00094   memset(mrc.beam_selection_mask, 0, sizeof(mrc.beam_selection_mask));
00095   mrc.beam_selection_mask[41] = 0xFF;
00096   mrc.beam_selection_mask[42] = 0xFF;
00097   mrc.beam_selection_mask[43] = 0x0F;
00098 
00099   EIP_BYTE d[110];
00100   EXPECT_EQ(sizeof(d), mrc.getLength());
00101   BufferWriter writer(buffer(d));
00102   mrc.serialize(writer);
00103   EXPECT_EQ(sizeof(d), writer.getByteCount());
00104 
00105   EXPECT_EQ(0x01, d[0]);
00106   EXPECT_EQ(0x00, d[1]);
00107   EXPECT_EQ(0x03, d[2]);
00108   EXPECT_EQ(0x00, d[3]);
00109   EXPECT_EQ(0x00, d[4]);
00110   EXPECT_EQ(0x00, d[5]);
00111   EXPECT_EQ(0x01, d[6]);
00112   EXPECT_EQ(0x00, d[7]);
00113   EXPECT_EQ(0x02, d[8]);
00114   EXPECT_EQ(0x00, d[9]);
00115   EXPECT_EQ(0x00, d[10]);
00116   EXPECT_EQ(0x00, d[11]);
00117   EXPECT_EQ(0x00, d[12]);
00118   EXPECT_EQ(0x00, d[13]);
00119   EXPECT_EQ(0x00, d[14]);
00120   EXPECT_EQ(0x00, d[15]);
00121   EXPECT_EQ(0x00, d[16]);
00122   EXPECT_EQ(0x00, d[17]);
00123   EXPECT_EQ(0x00, d[18]);
00124   EXPECT_EQ(0x00, d[19]);
00125   EXPECT_EQ(0x00, d[20]);
00126   EXPECT_EQ(0x00, d[21]);
00127   EXPECT_EQ(0x00, d[22]);
00128   EXPECT_EQ(0x00, d[23]);
00129   EXPECT_EQ(0x00, d[24]);
00130   EXPECT_EQ(0x00, d[25]);
00131   EXPECT_EQ(0x00, d[26]);
00132   EXPECT_EQ(0x00, d[27]);
00133   EXPECT_EQ(0x00, d[28]);
00134   EXPECT_EQ(0x00, d[29]);
00135   EXPECT_EQ(0x00, d[30]);
00136   EXPECT_EQ(0x00, d[31]);
00137   EXPECT_EQ(0x00, d[32]);
00138   EXPECT_EQ(0x00, d[33]);
00139   EXPECT_EQ(0x00, d[34]);
00140   EXPECT_EQ(0x00, d[35]);
00141   EXPECT_EQ(0x00, d[36]);
00142   EXPECT_EQ(0x00, d[37]);
00143   EXPECT_EQ(0x00, d[38]);
00144   EXPECT_EQ(0x00, d[39]);
00145   EXPECT_EQ(0x00, d[40]);
00146   EXPECT_EQ(0x00, d[41]);
00147   EXPECT_EQ(0x00, d[42]);
00148   EXPECT_EQ(0x00, d[43]);
00149   EXPECT_EQ(0x00, d[44]);
00150   EXPECT_EQ(0x00, d[45]);
00151   EXPECT_EQ(0x00, d[46]);
00152   EXPECT_EQ(0x00, d[47]);
00153   EXPECT_EQ(0x00, d[48]);
00154   EXPECT_EQ(0x00, d[49]);
00155   EXPECT_EQ(0x00, d[50]);
00156   EXPECT_EQ(0x00, d[51]);
00157   EXPECT_EQ(0x00, d[52]);
00158   EXPECT_EQ(0x00, d[53]);
00159   EXPECT_EQ(0x00, d[54]);
00160   EXPECT_EQ(0x00, d[55]);
00161   EXPECT_EQ(0x00, d[56]);
00162   EXPECT_EQ(0x00, d[57]);
00163   EXPECT_EQ(0x00, d[58]);
00164   EXPECT_EQ(0x00, d[59]);
00165   EXPECT_EQ(0x00, d[60]);
00166   EXPECT_EQ(0x00, d[61]);
00167   EXPECT_EQ(0x00, d[62]);
00168   EXPECT_EQ(0xFF, d[63]);
00169   EXPECT_EQ(0xFF, d[64]);
00170   EXPECT_EQ(0x0F, d[65]);
00171   EXPECT_EQ(0x00, d[66]);
00172   EXPECT_EQ(0x00, d[67]);
00173   EXPECT_EQ(0x00, d[68]);
00174   EXPECT_EQ(0x00, d[69]);
00175   EXPECT_EQ(0x00, d[70]);
00176   EXPECT_EQ(0x00, d[71]);
00177   EXPECT_EQ(0x00, d[72]);
00178   EXPECT_EQ(0x00, d[73]);
00179   EXPECT_EQ(0x00, d[74]);
00180   EXPECT_EQ(0x00, d[75]);
00181   EXPECT_EQ(0x00, d[76]);
00182   EXPECT_EQ(0x00, d[77]);
00183   EXPECT_EQ(0x00, d[78]);
00184   EXPECT_EQ(0x00, d[79]);
00185   EXPECT_EQ(0x00, d[80]);
00186   EXPECT_EQ(0x00, d[81]);
00187   EXPECT_EQ(0x00, d[82]);
00188   EXPECT_EQ(0x00, d[83]);
00189   EXPECT_EQ(0x00, d[84]);
00190   EXPECT_EQ(0x00, d[85]);
00191   EXPECT_EQ(0x00, d[86]);
00192   EXPECT_EQ(0x00, d[87]);
00193   EXPECT_EQ(0x00, d[88]);
00194   EXPECT_EQ(0x00, d[89]);
00195   EXPECT_EQ(0x00, d[90]);
00196   EXPECT_EQ(0x00, d[91]);
00197   EXPECT_EQ(0x00, d[92]);
00198   EXPECT_EQ(0x00, d[93]);
00199   EXPECT_EQ(0x00, d[94]);
00200   EXPECT_EQ(0x00, d[95]);
00201   EXPECT_EQ(0x00, d[96]);
00202   EXPECT_EQ(0x00, d[97]);
00203   EXPECT_EQ(0x00, d[98]);
00204   EXPECT_EQ(0x00, d[99]);
00205   EXPECT_EQ(0x00, d[100]);
00206   EXPECT_EQ(0x00, d[101]);
00207   EXPECT_EQ(0x00, d[102]);
00208   EXPECT_EQ(0x00, d[103]);
00209   EXPECT_EQ(0x00, d[104]);
00210   EXPECT_EQ(0x00, d[105]);
00211   EXPECT_EQ(0x00, d[106]);
00212   EXPECT_EQ(0x00, d[107]);
00213   EXPECT_EQ(0x00, d[108]);
00214   EXPECT_EQ(0x00, d[109]);
00215 }


omron_os32c_driver
Author(s): Kareem Shehata
autogenerated on Thu Jun 6 2019 19:00:54