Skip to content

test: add assertion-based unit tests (112 checks, no hardware deps)#112

Merged
GageLawton merged 2 commits into
mainfrom
claude/sleepy-feynman-SIYML
May 27, 2026
Merged

test: add assertion-based unit tests (112 checks, no hardware deps)#112
GageLawton merged 2 commits into
mainfrom
claude/sleepy-feynman-SIYML

Conversation

@GageLawton
Copy link
Copy Markdown
Owner

Summary

  • Adds test/test_unit.cpp — 112 assertion-based checks across 5 suites covering the pure-logic subsystems that previously had no correctness verification
  • Adds test/Makefile.unit — zero external dependencies (no libcurl, no hardware); just g++ and the project's own headers
  • Adds test/stubs/weather_stub.cpp — replaces src/weather.cpp in the unit build so the cache failure state machine can be tested without a network call
  • Updates .github/workflows/build.yml — inserts a Run unit tests step before the existing visualization harnesses

What's tested

Suite Checks
temperature cToF/fToC/toUnits conversions and round-trips
weather_alerts All 5 alert kinds; threshold boundary cases (79%, 80%, 85%); case-insensitive snow detection; priority ordering (SevereWeather first)
weather_cache shouldFetchNow, isStale, shouldAlert state machine; exponential backoff (30 → 60 → 120 → … → 600 s cap); backoff window respected by shouldFetchNow
display_rotation Screen cycling (Current → Today → Tomorrow → Alert → Current); stale asterisk; alert screen insertion/skip; Celsius mode; 16-char line clipping; no-forecast fallback
config JSON overrides; env-var priority; all sanity guards (sleep hours, I2C range, zero intervals, brightness clamp, all ENGINEERING_MODE truthy spellings)

Test plan

  • CI dev-build job passes with the new Run unit tests step green
  • make -f test/Makefile.unit run prints OK All 112 checks passed.
  • No new apt packages required (the unit build has no libcurl dependency)

claude added 2 commits May 27, 2026 11:49
112 checks across five suites:
  - temperature: cToF/fToC/toUnits conversions and round-trips
  - weather_alerts: all five alert kinds, threshold boundary cases,
    priority ordering, case-insensitive snow detection
  - weather_cache: shouldFetchNow, isStale, shouldAlert state machine,
    exponential backoff schedule (30/60/120…600 s cap)
  - display_rotation: screen cycling, stale asterisk, alert screen
    insertion, Celsius mode, line-length clipping, no-forecast fallback
  - config: JSON overrides, env-var priority, all sanity guards

test/stubs/weather_stub.cpp replaces src/weather.cpp so the unit build
has no libcurl dependency and runs without network access.

CI: unit tests run before the existing visualization harnesses in the
dev-build job (no new apt packages required).
Matches the pattern already established for other test binaries.
@GageLawton GageLawton self-assigned this May 27, 2026
@GageLawton GageLawton merged commit f2019c2 into main May 27, 2026
2 checks passed
@GageLawton GageLawton deleted the claude/sleepy-feynman-SIYML branch May 27, 2026 12:12
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.

2 participants