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 <cassert>
4#include <iostream>
5#include <utility>
6#include <vector>
7
10
12 // Mock class if a data saver is ever required but not the focus of the test
13 public:
14 // Store the calls and their parameters
15 std::vector<std::pair<DataPoint, uint8_t>> saveDataPointCalls;
16
17 // Mock saveDataPoint function
18 int saveDataPoint(const DataPoint& dp, uint8_t name) override {
19 saveDataPointCalls.emplace_back(dp, name);
20 return 0; // Return success
21 }
22
23 // Clear the stored calls
24 void clear() {
25 saveDataPointCalls.clear();
26 }
27
28 // Assertions
29 void assertSaveDataPointCalledWith(const DataPoint& expectedDp, uint8_t expectedName) {
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 return;
35 }
36 }
37
38 std::cerr << "Expected saveDataPoint call was not found in DataSaverMock.\n";
39 assert(false);
40 }
41};
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