mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
test: add native Unity env with Utils tests
Adds an [env:native] for host-side unit tests (pio test -e native) with a minimal Arduino.h stub, and covers the Utils helpers: _trim, toBoolean, SETCHARPROP, sortArray and the Timestamp conversions. The firmware envs now extend a shared [esp32] section instead of [env] so the native env doesn't inherit the Arduino framework, the ESP32 libraries or the build scripts. The half-hour calcTZOffset cases fail: +05:30 comes back as 2300. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1f394ca9df
commit
52c67b12f8
3 changed files with 242 additions and 4 deletions
20
test/stubs/Arduino.h
Normal file
20
test/stubs/Arduino.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Minimal stand-in for the Arduino core so firmware sources can be built for
|
||||
// the native test env (pio test -e native). Only add what tested code uses.
|
||||
#ifndef arduino_stub_h
|
||||
#define arduino_stub_h
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
|
||||
// Fixed so anything formatted from it is deterministic.
|
||||
inline unsigned long millis() { return 0; }
|
||||
inline bool getLocalTime(struct tm *info, uint32_t ms = 5000) {
|
||||
(void)ms;
|
||||
time_t now = time(nullptr);
|
||||
return localtime_r(&now, info) != nullptr;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue