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:

tests/HomeAutomation/LightControllerSpyTest.cpp
 
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:

tests/HomeAutomation/LightControllerSpy.h
 
int​ LightControllerSpy_GetLightState(​

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.