Add mock Arduino for x86_64 host-side testing
Complete Arduino API mock (mock_arduino.h/cpp) enabling application code to compile and run on PC without hardware. Includes MockSerial, String class, GPIO/analog/timing/interrupt mocks with state tracking and test control API. - Arduino.h, Wire.h, SPI.h shims intercept includes in test builds - System test template (test_system.cpp) using SimHal - CMakeLists.txt builds mock_arduino as static lib, links both suites - Root test.sh/test.bat with --unit/--system/--clean/--verbose flags - test.bat auto-detects MSVC via vswhere + vcvarsall.bat - Doctor reports nuanced compiler status (on PATH vs installed) - Refresh pulls mock infrastructure into existing projects - 15 tests passing: 7 unit (MockHal) + 8 system (SimHal)
This commit is contained in:
35
templates/basic/test/mocks/Wire.h
Normal file
35
templates/basic/test/mocks/Wire.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Wire.h -- shim for host-side test builds.
|
||||
*
|
||||
* Intercepts #include <Wire.h> so that code referencing Wire compiles
|
||||
* on x86_64. The mock Arduino state handles I2C through the HAL layer,
|
||||
* but if student code or libraries reference Wire directly, this
|
||||
* prevents a compile error.
|
||||
*
|
||||
* Generated by Anvil.
|
||||
*/
|
||||
#ifndef WIRE_H_MOCK_SHIM
|
||||
#define WIRE_H_MOCK_SHIM
|
||||
|
||||
#include "mock_arduino.h"
|
||||
|
||||
class MockWire {
|
||||
public:
|
||||
void begin() {}
|
||||
void begin(uint8_t) {}
|
||||
void beginTransmission(uint8_t) {}
|
||||
uint8_t endTransmission(bool sendStop = true) { (void)sendStop; return 0; }
|
||||
uint8_t requestFrom(uint8_t addr, uint8_t count, bool sendStop = true) {
|
||||
(void)addr; (void)count; (void)sendStop;
|
||||
return 0;
|
||||
}
|
||||
size_t write(uint8_t data) { (void)data; return 1; }
|
||||
size_t write(const uint8_t* data, size_t len) { (void)data; return len; }
|
||||
int available() { return 0; }
|
||||
int read() { return -1; }
|
||||
void setClock(uint32_t freq) { (void)freq; }
|
||||
};
|
||||
|
||||
extern MockWire Wire;
|
||||
|
||||
#endif // WIRE_H_MOCK_SHIM
|
||||
Reference in New Issue
Block a user