API
 
Loading...
Searching...
No Matches
telem_sparkleclock_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_sparkleclock.hpp"
5#include "../types/generated/telem_sparkleclock_generated.h"
6#include "../types/flatbuffer_log.hpp"
7
8/*
9 * GENERATED TEST FILE for types/telem_sparkleclock.hpp
10 * generated by generateTemplateCatch2Tests.py
11 */
12
13const bool telemSparkleclockModulating_0 = 1; // dummy modulating
14const bool telemSparkleclockTrigger_0 = 1; // dummy trigger
15const float telemSparkleclockFrequency_0 = 0.99894; // dummy frequency
16const float telemSparkleclockInterval_0 = 0.523278; // dummy interval
17const std::vector<float> telemSparkleclockSeparations_0 = { 0.159264,0.502858,0.988829,0.483864,0.014849,0.481233,0.721733,0.81682,0.095968,0.055461 }; // dummy separations
18const float telemSparkleclockAngleOffset_0 = 0.762991; // dummy angleOffset
19const float telemSparkleclockAmplitude_0 = 0.845377; // dummy amplitude
20
21
22/** Class to encapsulate telem_sparkleclock flatbuffer data using
23 ** => types/telem_sparkleclock.hpp
24 ** => types/generated/telem_sparkleclock_generated.h
25 **/
27{
28public:
29 // Saved input parameter value; unused
34 std::vector<float> m_saveTsSeparations;
37
38 // Parameters retrieved from flatbuffer
43 std::vector<float> m_separations;
46
47 // Flatbuffers verifier success/failure
48 bool m_verify{false};
49
50 // flatbuffer data length; used in ::verify
51 int L;
52
53 // Constructor
54 CTelemSparkleclock_0(bool modulating_, bool trigger_, float frequency_, float interval_, std::vector<float> separations_, float angleOffset_, float amplitude_) {
55 // Save input parameters
56 m_saveTsModulating = modulating_;
57 m_saveTsTrigger = trigger_;
58 m_saveTsFrequency = frequency_;
59 m_saveTsInterval = interval_;
60 m_saveTsSeparations = separations_;
61 m_saveTsAngleOffset = angleOffset_;
62 m_saveTsAmplitude = amplitude_;
63
64 // Create the flatbuffer messageT using the input parameters
65 auto ts = MagAOX::logger::telem_sparkleclock::messageT(modulating_, trigger_, frequency_, interval_, separations_, angleOffset_, amplitude_);
66
67 // Retrieve flatbuffer pointer (if not an empty_log type) and length
68 void* buffPtr = ts.builder.GetBufferPointer();
70
71 // Retrieve the flatbuffer parameters for Catch2 comparison below
76 if (MagAOX::logger::GetTelem_sparkleclock_fb(buffPtr)->separations() != nullptr)
77 {
78 for(auto it = MagAOX::logger::GetTelem_sparkleclock_fb(buffPtr)->separations()->begin();
79 it != MagAOX::logger::GetTelem_sparkleclock_fb(buffPtr)->separations()->end();
80 ++it)
81 {
82 m_separations.push_back(*it);
83 }
84 }
87
88 // Run the telem_sparkleclock verifier
89 m_verify = verify(ts);
90 }
91
92 // Run the flatbuffer Verifier for this log type
93 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
94 // comprising log header plus flatbuffer log message
96
97 // Timestamp, prioriy (use nominal value here)
98 flatlogs::timespecX tsx{0,0};
100
101 // Create full log: log header(*); log message (+)
102 // * Log level (priority)
103 // * Event code (implicit in <MagAOX::logger::type>)
104 // * Timestamp
105 // * Message size (variable length; 1, 2, or 8 bytes)
106 // + Message (variable length)
107
108 // N.G. allocates space and writes pointer value to logBuffer
109 flatlogs::bufferPtrT logBuffer;
110 flatlogs::logHeader::createLog<MagAOX::logger::telem_sparkleclock>(logBuffer
111 , tsx, msg
112 , prio);
113 // Run full log through flatbuffer Verifier
115 }
116};
117
118SCENARIO( "Create telem_sparkleclock 0", "[a log item]")
119{
120 GIVEN("a telem_sparkleclock log code")
121 {
122 WHEN("random values for fields")
123 {
124 // Create flatbuffer
126 // Compare flatbuffer parameters
134 REQUIRE(ts.m_verify);
135 }
136 }
137}
138
139
CTelemSparkleclock_0(bool modulating_, bool trigger_, float frequency_, float interval_, std::vector< float > separations_, float angleOffset_, float amplitude_)
bool verify(const typename MagAOX::logger::telem_sparkleclock::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_sparkleclock_fb * GetTelem_sparkleclock_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 float telemSparkleclockFrequency_0
const float telemSparkleclockAngleOffset_0
const float telemSparkleclockAmplitude_0
SCENARIO("Create telem_sparkleclock 0", "[a log item]")
const float telemSparkleclockInterval_0
const bool telemSparkleclockTrigger_0
const std::vector< float > telemSparkleclockSeparations_0
const bool telemSparkleclockModulating_0