test_serial_stream.cpp
Go to the documentation of this file.
1 
31 #include "create/data.h"
32 #include "create/serial_stream.h"
33 
34 #include "gtest/gtest.h"
35 
36 #include <boost/shared_ptr.hpp>
37 
38 TEST(SerialStreamTest, Constructor)
39 {
40  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
41  create::SerialStream serial_stream(data_ptr);
42 }
43 
44 TEST(SerialStreamTest, Connected)
45 {
46  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
47  create::SerialStream serial_stream(data_ptr);
48 
49  // Did not call connect and nothing to connect to, so expect false
50  EXPECT_FALSE(serial_stream.connected());
51 }
52 
53 TEST(SerialStreamTest, Disconnect)
54 {
55  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
56  create::SerialStream serial_stream(data_ptr);
57 
58  // Not connected, but should not fail
59  serial_stream.disconnect();
60 }
61 
62 TEST(SerialStreamTest, NumPackets)
63 {
64  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
65  create::SerialStream serial_stream(data_ptr);
66 
67  // Not connected, so zero packets should have been received
68  EXPECT_EQ(serial_stream.getNumCorruptPackets(), 0);
69  EXPECT_EQ(serial_stream.getTotalPackets(), 0);
70 }
71 
72 TEST(SerialStreamTest, Send)
73 {
74  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
75  create::SerialStream serial_stream(data_ptr);
76 
77  // Some bytes to send (to set date)
78  uint8_t bytes[4] = { create::OC_DATE, 0, 1, 2 };
79  // Not connected, so failure expected
80  EXPECT_FALSE(serial_stream.send(bytes, 4));
81 }
82 
83 TEST(SerialStreamTest, SendOpcode)
84 {
85  boost::shared_ptr<create::Data> data_ptr = boost::make_shared<create::Data>();
86  create::SerialStream serial_stream(data_ptr);
87 
88  // Not connected, so failure expected
89  EXPECT_FALSE(serial_stream.sendOpcode(create::OC_POWER));
90 }
TEST(SerialStreamTest, Constructor)


libcreate
Author(s): Jacob Perron
autogenerated on Sat Jun 8 2019 17:58:17