test_serial_query.cpp
Go to the documentation of this file.
00001 
00031 #include "create/data.h"
00032 #include "create/serial_query.h"
00033 
00034 #include "gtest/gtest.h"
00035 
00036 #include <boost/shared_ptr.hpp>
00037 
00038 TEST(SerialQueryTest, Constructor)
00039 {
00040   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00041   create::SerialQuery serial_query(data_ptr);
00042 }
00043 
00044 TEST(SerialQueryTest, Connected)
00045 {
00046   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00047   create::SerialQuery serial_query(data_ptr);
00048 
00049   // Did not call connect and nothing to connect to, so expect false
00050   EXPECT_FALSE(serial_query.connected());
00051 }
00052 
00053 TEST(SerialQueryTest, Disconnect)
00054 {
00055   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00056   create::SerialQuery serial_query(data_ptr);
00057 
00058   // Not connected, but should not fail
00059   serial_query.disconnect();
00060 }
00061 
00062 TEST(SerialQueryTest, NumPackets)
00063 {
00064   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00065   create::SerialQuery serial_query(data_ptr);
00066 
00067   // Not connected, so zero packets should have been received
00068   EXPECT_EQ(serial_query.getNumCorruptPackets(), 0);
00069   EXPECT_EQ(serial_query.getTotalPackets(), 0);
00070 }
00071 
00072 TEST(SerialQueryTest, Send)
00073 {
00074   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00075   create::SerialQuery serial_query(data_ptr);
00076 
00077   // Some bytes to send (to set date)
00078   uint8_t bytes[4] = { create::OC_DATE, 0, 1, 2 };
00079   // Not connected, so failure expected
00080   EXPECT_FALSE(serial_query.send(bytes, 4));
00081 }
00082 
00083 TEST(SerialQueryTest, SendOpcode)
00084 {
00085   boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
00086   create::SerialQuery serial_query(data_ptr);
00087 
00088   // Not connected, so failure expected
00089   EXPECT_FALSE(serial_query.sendOpcode(create::OC_POWER));
00090 }


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