Skip to Main Content
Test Driven Development for Embedded C
book

Test Driven Development for Embedded C

by James W. Grenning
April 2011
Intermediate to advanced content levelIntermediate to advanced
356 pages
8h 55m
English
Pragmatic Bookshelf
Content preview from Test Driven Development for Embedded C

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(​
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Design Patterns for Embedded Systems in C

Design Patterns for Embedded Systems in C

Bruce Powel Douglass

Publisher Resources

ISBN: 9781941222997Errata Page