Skip to content

Add GoogleTest harness with 22 unit tests#4

Open
billmallard wants to merge 4 commits into
makerplane:masterfrom
billmallard:master
Open

Add GoogleTest harness with 22 unit tests#4
billmallard wants to merge 4 commits into
makerplane:masterfrom
billmallard:master

Conversation

@billmallard
Copy link
Copy Markdown

Summary

  • Adds tests/CMakeLists.txt — CMake 3.12-compatible build (works with VS2017 bundled CMake); pulls GoogleTest 1.12.1 via FetchContent
  • Adds tests/mocks/can.h and tests/mocks/EEPROM.h — lightweight Arduino mock headers enabling native compilation outside the Arduino environment
  • Adds tests/mock_impl.cpp — global mock object instances
  • Adds tests/test_canfix.cpp — 22 tests across 5 suites:
    • CFParameterTest (7): FCB nibble pack/unpack for metadata and flags
    • CheckParamEnableTest (5): EEPROM bitmask enable/disable logic
    • SendParamTest (5): CAN frame ID, node number, index, FCB, and payload encoding
    • HandleFrameTest (3): ID-range routing to parameter and alarm callbacks
    • CanFixTest (2): getNodeNumber() EEPROM fallback behavior
  • All 22 tests pass with zero modifications to production code
  • Adds .gitignore to exclude the tests/build/ CMake output directory

Test plan

  • mkdir tests/build && cd tests/build
  • cmake .. (requires CMake 3.12+ and a C++14 compiler; GoogleTest fetched automatically)
  • cmake --build . --config Debug
  • ./Debug/canfix_tests (Windows) or ./canfix_tests (Linux/Mac) — all 22 tests should pass

🤖 Generated with Claude Code

billmallard and others added 4 commits April 18, 2026 06:36
Tests cover CFParameter FCB bit-field pack/unpack, checkParameterEnable
EEPROM bitmask logic, sendParam CAN frame encoding, handleFrame ID-range
routing, and getNodeNumber EEPROM fallback. Build system uses CMake 3.12
with FetchContent for GoogleTest; build/ directory is gitignored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 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