test: add assertion-based unit tests (112 checks, no hardware deps)#112
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test/test_unit.cpp— 112 assertion-based checks across 5 suites covering the pure-logic subsystems that previously had no correctness verificationtest/Makefile.unit— zero external dependencies (no libcurl, no hardware); justg++and the project's own headerstest/stubs/weather_stub.cpp— replacessrc/weather.cppin the unit build so the cache failure state machine can be tested without a network call.github/workflows/build.yml— inserts aRun unit testsstep before the existing visualization harnessesWhat's tested
temperaturecToF/fToC/toUnitsconversions and round-tripsweather_alertsweather_cacheshouldFetchNow,isStale,shouldAlertstate machine; exponential backoff (30 → 60 → 120 → … → 600 s cap); backoff window respected byshouldFetchNowdisplay_rotationconfigENGINEERING_MODEtruthy spellings)Test plan
dev-buildjob passes with the newRun unit testsstep greenmake -f test/Makefile.unit runprintsOK All 112 checks passed.