Make It Work for Many

To make the scheduler work for multiple scheduled items, we’re going to need to be able to check the state of multiple lights, something our current LightControllerSpy cannot do. Let’s evolve the LightControllerSpy to remember the state of each light like this:

 TEST(LightControllerSpy, RememberAllLightStates)
 {
  LightController_On(0);
  LightController_Off(31);
  LONGS_EQUAL(LIGHT_ON, LightControllerSpy_GetLightState(0));
  LONGS_EQUAL(LIGHT_OFF, LightControllerSpy_GetLightState(31));
 }

Add a new accessor to LightControllerSpy’s header file to allow any light’s state to be checked:

 int LightControllerSpy_GetLightState(int id); ...

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.