Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
DataSaver_mock.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <utility>
5#include <vector>
6
9
11 // Mock class if a data saver is ever required but not the focus of the test
12 public:
13 // Store the calls and their parameters
14 std::vector<std::pair<DataPoint, uint8_t>> saveDataPointCalls;
15
16 // Mock saveDataPoint function
17 int saveDataPoint(const DataPoint& dp, uint8_t name) override {
18 saveDataPointCalls.emplace_back(dp, name);
19 return 0; // Return success
20 }
21
22 // Clear the stored calls
23 void clear() {
24 saveDataPointCalls.clear();
25 }
26
27 // Assertions
28 void assertSaveDataPointCalledWith(const DataPoint& expectedDp, uint8_t expectedName) {
29 bool found = false;
30 for (const auto& call : saveDataPointCalls) {
31 if (call.first.timestamp_ms == expectedDp.timestamp_ms &&
32 call.first.data == expectedDp.data &&
33 call.second == expectedName) {
34 found = true;
35 break;
36 }
37 }
38 }
39};
Timestamped float measurement container.
Definition DataPoint.h:11
float data
Definition DataPoint.h:14
uint32_t timestamp_ms
Definition DataPoint.h:13
void assertSaveDataPointCalledWith(const DataPoint &expectedDp, uint8_t expectedName)
std::vector< std::pair< DataPoint, uint8_t > > saveDataPointCalls
int saveDataPoint(const DataPoint &dp, uint8_t name) override
Persist a data point with a source identifier.
Abstract interface for persisting timestamped data points.
Definition DataSaver.h:13