Please participate in my research by doing a little C programming
Objective
Write a CircularBuffer module in c and test it.Requirements
A CircularBuffer is sized during create. It stores integers. If you put to a full
CircularBuffer, it returns false. If you get from and empty CircularBuffer
it returns the default value provided during create. It is FIFO.
Here is a diagram of some of the CircularBuffer states.
Starting point
You have the CircularBuffer interface in CircularBuffer.h. You must develop to that interface. The architects said so.
Here is the interface you will implement:
struct CircularBuffer;struct CircularBuffer * CircularBuffer_Create(unsigned int capacity, int default_value); void CircularBuffer_Destroy(struct CircularBuffer *); bool CircularBuffer_IsEmpty(struct CircularBuffer *); bool CircularBuffer_IsFull(struct CircularBuffer *); bool CircularBuffer_Put(struct CircularBuffer *, int); int CircularBuffer_Get(struct CircularBuffer *); unsigned int CircularBuffer_Capacity(struct CircularBuffer *);
Instructions for non-TDD programmers
Write CircularBuffer.c. Once it compiles, test that the CircularBuffer is working. Use the provided main.c to exercise your CircularBuffer. Do not use any unit test framework.
Note in main.c that there is a exercise_state variable. It is initially set to writing. Once you finish writing code, set and are going to start testing, set the variable to testing. Once you are satisfied that your code works, set it to working.
Email us once you have completed you CircularBuffer. Include exercise URL
This will probably take an hour or two to complete. If you want to do it, please follow these steps. Exercise slots are limited, so contact us if there the server runs out of slots.
Instructions for TDD programmers
Test-Drive CircularBuffer.c. Once you are finished, email james@wingman-sw.com. Include exercise URL
This will probably take an hour or two to complete. If you want to do it, please follow these steps. Exercise slots are limited, so contact us if there the server runs out of slots.
Do the exercise in my cyberdojo server
After you click this link
Programmers NOT experienced in TDD press 'enter' on the non-TDD exercise page.
Programmers EXPERIENCED in TDD press 'enter' on the TDD exercise page.
Tweet
Published: February 14, 2015
Latest News
Conference Video - Deep Stack – Tracer Bullets from ADC to Browser
A blank page can be very intimidating, even for a Test-driven developer. Where do we start? Write a test, right? Not always.
more...Podcast on Agile Amped
Here is a short interview with James about TDD and embedded software from the deliver:Agile conference last spring.
more...Programming Research -- Please Participate
Do you have some time to do a simple programming problem in C or C++ for my research?
more...Clean Coders IoT Case Study
My long-time good friend (Uncle) Bob Martin and I have fun programming together firing tracer bullets for distributed water pressure measurement system.
more...Books
James is the author of Test-Driven Development for Embedded C.
Have you read Test-Driven Development for Embedded C? Please write a review at
Amazon
or
Good Reads
.