API
 
Loading...
Searching...
No Matches
ttmmod_params_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/ttmmod_params.hpp"
5#include "../types/generated/ttmmod_params_generated.h"
6#include "../types/flatbuffer_log.hpp"
7
8/*
9 * GENERATED TEST FILE for types/ttmmod_params.hpp
10 * generated by generateTemplateCatch2Tests.py
11 */
12
13const uint8_t ttmmodParamsModState_0 = 226; // dummy modState
14const double ttmmodParamsModFreq_0 = 0.34183528073191; // dummy modFreq
15const double ttmmodParamsModRad_0 = 0.78340685991408; // dummy modRad
16const double ttmmodParamsOffset1_0 = 0.0944568558764; // dummy offset1
17const double ttmmodParamsOffset2_0 = 0.87414524499711; // dummy offset2
18
19
20/** Class to encapsulate ttmmod_params flatbuffer data using
21 ** => types/ttmmod_params.hpp
22 ** => types/generated/ttmmod_params_generated.h
23 **/
25{
26public:
27 // Saved input parameter value; unused
33
34 // Parameters retrieved from flatbuffer
35 uint8_t m_modState;
36 double m_modFreq;
37 double m_modRad;
38 double m_offset1;
39 double m_offset2;
40
41 // Flatbuffers verifier success/failure
42 bool m_verify{false};
43
44 // flatbuffer data length; used in ::verify
45 int L;
46
47 // Constructor
48 CTtmmodParams_0(uint8_t modState_, double modFreq_, double modRad_, double offset1_, double offset2_) {
49 // Save input parameters
50 m_saveTpModState = modState_;
51 m_saveTpModFreq = modFreq_;
52 m_saveTpModRad = modRad_;
53 m_saveTpOffset1 = offset1_;
54 m_saveTpOffset2 = offset2_;
55
56 // Create the flatbuffer messageT using the input parameters
57 auto tp = MagAOX::logger::ttmmod_params::messageT(modState_, modFreq_, modRad_, offset1_, offset2_);
58
59 // Retrieve flatbuffer pointer (if not an empty_log type) and length
60 void* buffPtr = tp.builder.GetBufferPointer();
62
63 // Retrieve the flatbuffer parameters for Catch2 comparison below
69
70 // Run the ttmmod_params verifier
71 m_verify = verify(tp);
72 }
73
74 // Run the flatbuffer Verifier for this log type
75 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
76 // comprising log header plus flatbuffer log message
78
79 // Timestamp, prioriy (use nominal value here)
80 flatlogs::timespecX tsx{0,0};
82
83 // Create full log: log header(*); log message (+)
84 // * Log level (priority)
85 // * Event code (implicit in <MagAOX::logger::type>)
86 // * Timestamp
87 // * Message size (variable length; 1, 2, or 8 bytes)
88 // + Message (variable length)
89
90 // N.G. allocates space and writes pointer value to logBuffer
91 flatlogs::bufferPtrT logBuffer;
92 flatlogs::logHeader::createLog<MagAOX::logger::ttmmod_params>(logBuffer
93 , tsx, msg
94 , prio);
95 // Run full log through flatbuffer Verifier
97 }
98};
99
100SCENARIO( "Create ttmmod_params 0", "[a log item]")
101{
102 GIVEN("a ttmmod_params log code")
103 {
104 WHEN("random values for fields")
105 {
106 // Create flatbuffer
108 // Compare flatbuffer parameters
109 REQUIRE(tp.m_modState == ttmmodParamsModState_0);
110 REQUIRE(tp.m_modFreq == ttmmodParamsModFreq_0);
111 REQUIRE(tp.m_modRad == ttmmodParamsModRad_0);
112 REQUIRE(tp.m_offset1 == ttmmodParamsOffset1_0);
113 REQUIRE(tp.m_offset2 == ttmmodParamsOffset2_0);
114 REQUIRE(tp.m_verify);
115 }
116 }
117}
118
119
CTtmmodParams_0(uint8_t modState_, double modFreq_, double modRad_, double offset1_, double offset2_)
bool verify(const typename MagAOX::logger::ttmmod_params::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::Ttmmod_params_fb * GetTtmmod_params_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.
The type of the input message.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
A fixed-width timespec structure.
Definition timespecX.hpp:35
const double ttmmodParamsOffset1_0
SCENARIO("Create ttmmod_params 0", "[a log item]")
const double ttmmodParamsModFreq_0
const uint8_t ttmmodParamsModState_0
const double ttmmodParamsOffset2_0
const double ttmmodParamsModRad_0