Please participate in my research by doing a little C programming

I hope you can have a little fun programming today.

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

  • Press the 'enter' button
  • Press the 'test' button
  • Review the instructions
  • Complete the exercise from within the cyber-dojo development environment

  • Programmers NOT experienced in TDD press 'enter' on the non-TDD exercise page.
    Programmers EXPERIENCED in TDD press 'enter' on the TDD exercise page.


    Published: February 14, 2015