ESPSomfy-RTS/test/stubs/Arduino.h
cjkas 52c67b12f8 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>
2026-10-11 12:54:39 +02:00

20 lines
591 B
C++

// 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