API
 
Loading...
Searching...
No Matches
ao_operator_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/ao_operator.hpp"
5#include "../types/flatbuffer_log.hpp"
6
7/*
8 * GENERATED TEST FILE for types/ao_operator.hpp
9 * generated by generateTemplateCatch2Tests.py
10 */
11
12const std::string aoOperatorFullName_0 = "xkjbhqe1lj"; // dummy fullName
13const std::string aoOperatorPfoa_0 = "34yufibr14"; // dummy pfoa
14const std::string aoOperatorEmail_0 = "57y4qppfc2"; // dummy email
15const std::string aoOperatorInstitution_0 = "go0aoy33ne"; // dummy institution
16
17
18/** Class to encapsulate ao_operator flatbuffer data using
19 ** => types/ao_operator.hpp
20 ** => types/generated/ao_operator_generated.h
21 **/
23{
24public:
25 // Saved input parameter value; unused
26 std::string m_saveAoFullName;
27 std::string m_saveAoPfoa;
28 std::string m_saveAoEmail;
30
31 // Parameters retrieved from flatbuffer
32 std::string m_fullName;
33 std::string m_pfoa;
34 std::string m_email;
35 std::string m_institution;
36
37 // Flatbuffers verifier success/failure
38 bool m_verify{false};
39
40 // flatbuffer data length; used in ::verify
41 int L;
42
43 // Constructor
44 CAoOperator_0(std::string fullName_, std::string pfoa_, std::string email_, std::string institution_) {
45 // Save input parameters
46 m_saveAoFullName = fullName_;
47 m_saveAoPfoa = pfoa_;
48 m_saveAoEmail = email_;
49 m_saveAoInstitution = institution_;
50
51 // Create the flatbuffer messageT using the input parameters
52 auto ao = MagAOX::logger::ao_operator::messageT(fullName_, pfoa_, email_, institution_);
53
54 // Retrieve flatbuffer pointer (if not an empty_log type) and length
55 void* buffPtr = ao.builder.GetBufferPointer();
57
58 // Retrieve the flatbuffer parameters for Catch2 comparison below
59 m_fullName = std::string(MagAOX::logger::GetObserver_fb(buffPtr)->fullName()->c_str());
60 m_pfoa = std::string(MagAOX::logger::GetObserver_fb(buffPtr)->pfoa()->c_str());
61 m_email = std::string(MagAOX::logger::GetObserver_fb(buffPtr)->email()->c_str());
62 m_institution = std::string(MagAOX::logger::GetObserver_fb(buffPtr)->institution()->c_str());
63
64 // Run the ao_operator verifier
65 m_verify = verify(ao);
66 }
67
68 // Run the flatbuffer Verifier for this log type
69 // - requires bufferPtrT (shared_ptr<char*>) to full log entry
70 // comprising log header plus flatbuffer log message
72
73 // Timestamp, prioriy (use nominal value here)
74 flatlogs::timespecX tsx{0,0};
76
77 // Create full log: log header(*); log message (+)
78 // * Log level (priority)
79 // * Event code (implicit in <MagAOX::logger::type>)
80 // * Timestamp
81 // * Message size (variable length; 1, 2, or 8 bytes)
82 // + Message (variable length)
83
84 // N.G. allocates space and writes pointer value to logBuffer
85 flatlogs::bufferPtrT logBuffer;
86 flatlogs::logHeader::createLog<MagAOX::logger::ao_operator>(logBuffer
87 , tsx, msg
88 , prio);
89 // Run full log through flatbuffer Verifier
90 return MagAOX::logger::ao_operator::verify(logBuffer,L);
91 }
92};
93
94SCENARIO( "Create ao_operator 0", "[a log item]")
95{
96 GIVEN("a ao_operator log code")
97 {
98 WHEN("random values for fields")
99 {
100 // Create flatbuffer
102 // Compare flatbuffer parameters
103 REQUIRE(ao.m_fullName == aoOperatorFullName_0);
104 REQUIRE(ao.m_pfoa == aoOperatorPfoa_0);
105 REQUIRE(ao.m_email == aoOperatorEmail_0);
107 REQUIRE(ao.m_verify);
108 }
109 }
110}
111
112
const std::string aoOperatorFullName_0
const std::string aoOperatorEmail_0
SCENARIO("Create ao_operator 0", "[a log item]")
const std::string aoOperatorPfoa_0
const std::string aoOperatorInstitution_0
bool verify(const typename MagAOX::logger::ao_operator::messageT &msg)
CAoOperator_0(std::string fullName_, std::string pfoa_, std::string email_, std::string institution_)
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::Observer_fb * GetObserver_fb(const void *buf)
static constexpr logPrioT LOG_DEFAULT
Used to denote "use the default level for this log type".
The type of the input message.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static flatlogs::msgLenT length(const fbMessage &msg)
Get the length of the message.
A fixed-width timespec structure.
Definition timespecX.hpp:35