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 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.