Grow the Solution from Simple Beginnings

The simple-minded implementation in the previous chapter gets more robust incrementally. Each test drives the implementation to a more complete state.

The next test turns on a couple of LEDs. That is enough to force a more general and complete implementation. Notice which LEDs are turned on in the test that follows, and see if you can easily determine whether the expected value in virtualLeds is correct.

 TEST(LedDriver, TurnOnMultipleLeds)
 {
  LedDriver_TurnOn(9);
  LedDriver_TurnOn(8);
  TEST_ASSERT_EQUAL_HEX16(0x180, virtualLeds);
 }

Tests are documentation, and a good document should be easy to understand. If you want well-written tests, you must carefully select ...

Get Test Driven Development for Embedded C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.