API
 
Loading...
Searching...
No Matches
telem_chrony_status_generated_tests.cpp
Go to the documentation of this file.
1#include <assert.h>
2#include "../../../../tests/catch2/catch.hpp"
3#include "../generated/logCodes.hpp"
4#include "../types/telem_chrony_status.hpp"
5#include "../types/generated/telem_chrony_status_generated.h"
6#include "../types/flatbuffer_log.hpp"
7
8/*
9 * GENERATED TEST FILE for types/telem_chrony_status.hpp
10 * generated by generateTemplateCatch2Tests.py
11 */
12
13const std::string telemChronyStatusMac_0 = "jv91bdxcpe"; // dummy mac
14const std::string telemChronyStatusIp_0 = "326qrvgv9r"; // dummy ip
15const std::string telemChronyStatusSync_0 = "cx8j28cihu"; // dummy sync
16const std::string telemChronyStatusLeap_0 = "ywnx6hr0nc"; // dummy leap
17
18
19/** Class to encapsulate telem_chrony_status flatbuffer data using
20 ** => types/telem_chrony_status.hpp
21 ** => types/generated/telem_chrony_status_generated.h
22 **/
24{
25public:
26 // Saved input parameter value; unused
27 std::string m_saveTcsMac;
28 std::string m_saveTcsIp;
29 std::string m_saveTcsSync;
30 std::string m_saveTcsLeap;
31
32 // Parameters retrieved from flatbuffer
33 std::string m_mac;
34 std::string m_ip;
35 std::string m_sync;
36 std::string m_leap;
37
38 // Flatbuffers verifier success/failure
39 bool m_verify{false};
40
41 // flatbuffer data length; used in ::verify
42 int L;
43
44 // Constructor
45 CTelemChronyStatus_0(std::string mac_, std::string ip_, std::string sync_, std::string leap_) {
46 // Save input parameters
47 m_saveTcsMac = mac_;
48 m_saveTcsIp = ip_;
49 m_saveTcsSync = sync_;
50 m_saveTcsLeap = leap_;
51
52 // Create the flatbuffer messageT using the input parameters
53 auto tcs = MagAOX::logger::telem_chrony_status::messageT(mac_, ip_, sync_, leap_);
54
55 // Retrieve flatbuffer pointer (if not an empty_log type) and length
56 void* buffPtr = tcs.builder.GetBufferPointer();
58
59 // Retrieve the flatbuffer parameters for Catch2 comparison below
60 m_mac = std::string(MagAOX::logger::GetTelem_chrony_status_fb(buffPtr)->sourceMAC()->c_str());
61 m_ip = std::string(MagAOX::logger::GetTelem_chrony_status_fb(buffPtr)->sourceIP()->c_str());
62 m_sync = std::string(MagAOX::logger::GetTelem_chrony_status_fb(buffPtr)->synch()->c_str());
63 m_leap = std::string(MagAOX::logger::GetTelem_chrony_status_fb(buffPtr)->leap()->c_str());
64
65 // Run the telem_chrony_status verifier
66 m_verify = verify(tcs);
67 }
68
69 // Run the flatbuffer Verifier for this log type
70 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
71 // comprising log header plus flatbuffer log message
73
74 // Timestamp, prioriy (use nominal value here)
75 flatlogs::timespecX tsx{0,0};
77
78 // Create full log: log header(*); log message (+)
79 // * Log level (priority)
80 // * Event code (implicit in <MagAOX::logger::type>)
81 // * Timestamp
82 // * Message size (variable length; 1, 2, or 8 bytes)
83 // + Message (variable length)
84
85 // N.G. allocates space and writes pointer value to logBuffer
86 flatlogs::bufferPtrT logBuffer;
87 flatlogs::logHeader::createLog<MagAOX::logger::telem_chrony_status>(logBuffer
88 , tsx, msg
89 , prio);
90 // Run full log through flatbuffer Verifier
92 }
93};
94
95SCENARIO( "Create telem_chrony_status 0", "[a log item]")
96{
97 GIVEN("a telem_chrony_status log code")
98 {
99 WHEN("random values for fields")
100 {
101 // Create flatbuffer
103 // Compare flatbuffer parameters
104 REQUIRE(tcs.m_mac == telemChronyStatusMac_0);
105 REQUIRE(tcs.m_ip == telemChronyStatusIp_0);
106 REQUIRE(tcs.m_sync == telemChronyStatusSync_0);
107 REQUIRE(tcs.m_leap == telemChronyStatusLeap_0);
108 REQUIRE(tcs.m_verify);
109 }
110 }
111}
112
113
CTelemChronyStatus_0(std::string mac_, std::string ip_, std::string sync_, std::string leap_)
bool verify(const typename MagAOX::logger::telem_chrony_status::messageT &msg)
int8_t logPrioT
The type of the log priority code.
Definition logDefs.hpp:21
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition logHeader.hpp:58
const MagAOX::logger::Telem_chrony_status_fb * GetTelem_chrony_status_fb(const void *buf)
static constexpr logPrioT LOG_DEFAULT
Used to denote "use the default level for this log type".
static flatlogs::msgLenT length(const fbMessage &msg)
Get the length of the message.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
A fixed-width timespec structure.
Definition timespecX.hpp:35
const std::string telemChronyStatusIp_0
const std::string telemChronyStatusMac_0
const std::string telemChronyStatusLeap_0
SCENARIO("Create telem_chrony_status 0", "[a log item]")
const std::string telemChronyStatusSync_0