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

Test-Driving the Driver

Before we looked under the hood of MockIO, Flash_Write passed a simple test where the device is immediately ready. It is not likely that the device would be ready right away. According to its specification, this device has a typical write time of ten microseconds. When the driver runs in a real device, the StatusRegister may be read hundreds or thousands of times. The driver needs to loop, waiting for the operation to complete, though we can prove the looping logic with just a few reads:

tests/IO/FlashTest.cpp
 
TEST(Flash, WriteSucceeds_NotImmediatelyReady)
 
{
 
MockIO_Expect_Write(CommandRegister, ProgramCommand);
 
MockIO_Expect_Write(address, data);
 
MockIO_Expect_ReadThenReturn(StatusRegister, 0);
 
MockIO_Expect_ReadThenReturn(StatusRegister, ...
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