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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.