Skip to content

test: add host-side unit tests for stats.h pure logic#37

Closed
Swissola wants to merge 4 commits into
anthropics:mainfrom
Swissola:test/stats-unit-tests
Closed

test: add host-side unit tests for stats.h pure logic#37
Swissola wants to merge 4 commits into
anthropics:mainfrom
Swissola:test/stats-unit-tests

Conversation

@Swissola
Copy link
Copy Markdown

Summary

  • Add PlatformIO native environment to platformio.ini
  • Add Arduino.h and Preferences.h stubs for host-side compilation
  • Add 27 Unity test cases covering the four pure-logic functions in stats.h

Motivation

stats.h contains non-trivial pure logic — median calculation, mood tier thresholds, energy drain, token level progression — that was previously only verifiable by flashing the device. These functions have no hardware dependency and are exactly the kind of thing a unit test suite should cover.

To run: pio test -e native (requires GCC/MinGW or MSVC on PATH)

Coverage

Function Cases What's tested
statsMedianVelocity 6 empty, single value, odd/even counts, ring buffer wrap
statsMoodTier 8 velocity bands, denial penalty thresholds, floor clamp
statsEnergyTier 4 boot default, post-wake, 2h drain cadence, floor at zero
statsFedProgress 5 pip boundaries, level-up reset, second level
statsOnBridgeTokens 4 first-packet latch, delta, bridge restart resync, level-up flag

Notes

  • test/stubs/ contains minimal no-op stubs for Arduino.h and Preferences.h
  • _mock_millis in the Arduino stub lets tests control the clock precisely
  • setUp() resets all file-static state between tests

🤖 Generated with Claude Code

Swissola and others added 4 commits May 22, 2026 17:37
sleep=Donald Duck, idle=Bongo Cat, busy=SpongeBob multitasking,
attention=Surprised Pikachu (Nouns glasses), celebrate=Peanuts party,
dizzy=Powerpuff Girls spiral eyes, heart=heart eyes ghost.

Source GIFs in characters/memes-src/, device-ready pack in characters/memes/.
Built with prep_character.py at 96x98px, 64 colours per frame.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track the current peer BD address in onConnect (extended overload).
bleRemoveCurrentBond() removes only that peer's LTK from NVS. The
"unpair" JSON command now calls this instead of bleClearBonds(), so
each host unpairs itself independently. bleClearBonds() is reserved
for factory reset only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PlatformIO native environment + Unity test framework covering:
- statsMedianVelocity: empty, single, odd/even counts, ring wrap
- statsMoodTier: velocity tiers, denial penalty thresholds, floor
- statsEnergyTier: boot default, wake, 2h drain cadence
- statsFedProgress: pip boundaries, level-up reset
- statsOnBridgeTokens: first-packet latch, delta, restart resync, level-up

Run with: pio test -e native  (requires GCC/MinGW or MSVC on PATH)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Unity source is now part of the repo so no curl step is needed.
Run command in test_main.cpp updated accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Swissola
Copy link
Copy Markdown
Author

Closing as this is outside the scope of the upstream reference implementation per CONTRIBUTING.md. This change is maintained in the community fork at https://github.com/Swissola/claude-desktop-buddy — see the enhance/haptics-and-settings branch.

@Swissola Swissola closed this May 23, 2026
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