test_serial_query.cpp
Go to the documentation of this file.
1 
31 #include "create/data.h"
32 #include "create/serial_query.h"
33 
34 #include "gtest/gtest.h"
35 
36 #include <memory>
37 
38 TEST(SerialQueryTest, Constructor)
39 {
40  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
41  create::SerialQuery serial_query(data_ptr);
42 }
43 
44 TEST(SerialQueryTest, Connected)
45 {
46  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
47  create::SerialQuery serial_query(data_ptr);
48 
49  // Did not call connect and nothing to connect to, so expect false
50  EXPECT_FALSE(serial_query.connected());
51 }
52 
53 TEST(SerialQueryTest, Disconnect)
54 {
55  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
56  create::SerialQuery serial_query(data_ptr);
57 
58  // Not connected, but should not fail
59  serial_query.disconnect();
60 }
61 
62 TEST(SerialQueryTest, NumPackets)
63 {
64  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
65  create::SerialQuery serial_query(data_ptr);
66 
67  // Not connected, so zero packets should have been received
68  EXPECT_EQ(serial_query.getNumCorruptPackets(), 0);
69  EXPECT_EQ(serial_query.getTotalPackets(), 0);
70 }
71 
72 TEST(SerialQueryTest, Send)
73 {
74  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
75  create::SerialQuery serial_query(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_query.send(bytes, 4));
81 }
82 
83 TEST(SerialQueryTest, SendOpcode)
84 {
85  std::shared_ptr<create::Data> data_ptr = std::make_shared<create::Data>();
86  create::SerialQuery serial_query(data_ptr);
87 
88  // Not connected, so failure expected
89  EXPECT_FALSE(serial_query.sendOpcode(create::OC_POWER));
90 }
TEST(SerialQueryTest, Constructor)


libcreate
Author(s): Jacob Perron
autogenerated on Sat May 8 2021 03:02:37