test_packet.cpp
Go to the documentation of this file.
00001 
00031 #include "create/packet.h"
00032 #include "create/types.h"
00033 
00034 #include "gtest/gtest.h"
00035 
00036 TEST(PacketTest, Constructor)
00037 {
00038   create::Packet empty_packet(0, std::string(""));
00039   EXPECT_EQ(static_cast<int>(empty_packet.nbytes), 0);
00040   EXPECT_EQ(empty_packet.info, std::string(""));
00041 
00042   create::Packet some_packet(2, std::string("test_packet"));
00043   EXPECT_EQ(static_cast<int>(some_packet.nbytes), 2);
00044   EXPECT_EQ(some_packet.info, std::string("test_packet"));
00045 }
00046 
00047 TEST(PacketTest, SetValidateAndGetData)
00048 {
00049   create::Packet packet(2, std::string("test_packet"));
00050 
00051   // Set some data and validate it
00052   const uint16_t some_data = 123;
00053   packet.setDataToValidate(some_data);
00054   packet.validate();
00055   // Confirm data was validated
00056   const uint16_t some_data_result = packet.getData();
00057   EXPECT_EQ(some_data_result, some_data);
00058 
00059   // Set zero data and validate it
00060   const uint16_t zero_data = 0;
00061   packet.setDataToValidate(zero_data);
00062   packet.validate();
00063   // Confirm data was validated
00064   const uint16_t zero_data_result = packet.getData();
00065   EXPECT_EQ(zero_data_result, zero_data);
00066 
00067   // Set some data but do not validate it
00068   const uint16_t do_not_validate_data = 321;
00069   packet.setDataToValidate(do_not_validate_data);
00070   // Confirm data was not validated
00071   const uint16_t unvalidated_data_result = packet.getData();
00072   EXPECT_NE(unvalidated_data_result, do_not_validate_data);
00073 }


libcreate
Author(s): Jacob Perron
autogenerated on Thu Jun 6 2019 21:02:06