Skip to content

Add native host unit tests for Packet and StrHelper#1837

Open
andrewdefilippis wants to merge 1 commit intomeshcore-dev:devfrom
andrewdefilippis:add-native-unit-tests
Open

Add native host unit tests for Packet and StrHelper#1837
andrewdefilippis wants to merge 1 commit intomeshcore-dev:devfrom
andrewdefilippis:add-native-unit-tests

Conversation

@andrewdefilippis
Copy link

@andrewdefilippis andrewdefilippis commented Feb 25, 2026

Adds tests; raises bug in StrHelper::ftoa3().

Enable PlatformIO native-platform testing with GoogleTest to allow
host-based verification of core logic without hardware. This is a
minimal proof-of-concept covering two pure-C++ modules (Packet and
TxtDataHelpers/StrHelper) with 41 tests and zero changes to existing
source code.

Key additions:
- [env:native] section in platformio.ini for `pio test -e native`
- Arduino.h compatibility shim (millis, micros, ltoa) for native builds
- 16 tests for Packet (serialization round-trips, header fields,
  hash computation, bad-input rejection, SNR conversion)
- 25 tests for StrHelper (strncpy, strzcpy, isBlank, fromHex, ftoa,
  ftoa3 including a documented sign-loss bug for values in (-1, 0))

Note: ftoa3() drops the negative sign for floats in the range (-1.0, 0.0)
due to integer division truncation. The test documents this as a known bug
with root-cause analysis. Current impact is low (sole call site uses
positive values) but the function is a general-purpose utility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
andrewdefilippis added a commit to andrewdefilippis/MeshCore that referenced this pull request Feb 25, 2026
Research doc covers framework comparisons (GoogleTest, Unity, Catch2,
CppUTest, doctest) and mocking strategies for MeshCore's abstract
interfaces. Plan doc details the implemented proof-of-concept PR meshcore-dev#1837
including implementation corrections discovered during development.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant