Fixing unit tests and formatting

This commit is contained in:
Matt Holmes 2025-08-27 19:14:54 +01:00
parent 588c78f1d6
commit 5fae1c645d
8 changed files with 48 additions and 18 deletions

View file

@ -1,8 +1,8 @@
#include "comm_can.h"
#include <algorithm>
#include <map>
#include "../../lib/pierremolinaro-acan-esp32/ACAN_ESP32.h"
#include "../../lib/pierremolinaro-ACAN2517FD/ACAN2517FD.h"
#include "../../lib/pierremolinaro-acan-esp32/ACAN_ESP32.h"
#include "../../lib/pierremolinaro-acan2515/ACAN2515.h"
#include "CanReceiver.h"
#include "USER_SETTINGS.h"
@ -90,8 +90,7 @@ bool init_CAN() {
settingsespcan->mRxPin = rx_pin;
const uint32_t errorCode = ACAN_ESP32::can.begin(*settingsespcan);
if (errorCode == 0)
{
if (errorCode == 0) {
native_can_initialized = true;
#ifdef DEBUG_LOG
logging.println("Native Can ok");

View file

@ -2,6 +2,7 @@
#define _COMM_NVM_H_
#include <Preferences.h>
#include <WString.h>
#include <limits>
#include "../../datalayer/datalayer.h"
#include "../../devboard/utils/events.h"

View file

@ -4,10 +4,10 @@
#include <soc/gpio_num.h>
#include <chrono>
#include <unordered_map>
#include "../../../src/communication/nvm/comm_nvm.h"
#include "../../../src/devboard/utils/events.h"
#include "../../../src/devboard/utils/logging.h"
#include "../../../src/devboard/utils/types.h"
#include <src/communication/nvm/comm_nvm.h>
// Hardware Abstraction Layer base class.
// Derive a class to define board-specific parameters such as GPIO pin numbers

27
test/emul/Preferences.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef PREFERENCES
#define PREFERENCES
#include <stdint.h>
class Preferences {
public:
Preferences() {}
bool begin(const char *name, bool readOnly = false, const char *partition_label = NULL);
void end();
bool clear();
size_t putUInt(const char *key, uint32_t value) { return 0; }
size_t putBool(const char *key, bool value) { return 0; }
size_t putString(const char *key, const char *value) { return 0; }
size_t putString(const char *key, String value) { return 0; }
bool isKey(const char *key) { return false; }
uint32_t getUInt(const char *key, uint32_t defaultValue = 0) { return 0; }
bool getBool(const char *key, bool defaultValue = false) { return false; }
size_t getString(const char *key, char *value, size_t maxLen) { return 0; }
String getString(const char *key, String defaultValue = String()) { return String(); }
};
#endif

View file

@ -43,6 +43,9 @@ class String {
// Accessor
const std::string& str() const { return data; }
// Comparison operators
bool operator==(const String& rhs) const { return data == rhs.data; }
// Concatenation
String operator+(const String& rhs) const { return String(data + rhs.data); }