c programming

sehj
a31.pdf

COMP 2160 Programming Practices

Assignment 3

Page 1 of 2

Due Date: March 14th at 11:59pm

NOTES  Please read and follow instructions carefully; not doing so will result in a loss of marks.  Your code must follow the programming standards (available in UMLearn).  You can write your code on any machines; remember to verify your code on one of the lab machines.  You must include a README file which describes how to compile and run your solution. You can

also explain your concerns or personal opinions regarding this assignment.  Use submission tool (handin) in CS Unix system as described in Assignment Submission

Guidelines (available in UMLearn).

Q1: DESIGN BY CONTRACT [10] In this problem, you will create an implementation of the Table abstract data type (ADT). A Table is a data type that allows for a few simple operations on a collection of data:

 Insertion  Removal  Searching for presence  Iteration

Using the provided interface table.h and the sample linked list code linkedlist_int.c, complete an implementation of the Table ADT. Make sure that you apply the concepts of design by contract (DbC) to your implementation.

Once you have fully implemented the table, create a main.c file that implements a testing framework for your table.

Your table implementation must ensure that values inserted are unique, and internally sorted in ascending order (i.e., head points the lowest value) within a linked list. This is an implementation detail of your table, and not part of the public interface. Be sure to only test what is known from the public interface (i.e., black box testing).

Make sure you test with assertions turned off. Boundary conditions should not cause the program to crash. Remember that to turn off assertions you can compile with -DNDEBUG. Include a Makefile (along with all your source files) for your implementation.

COMP 2160 Programming Practices

Assignment 3

Page 2 of 2

Q2: SET (TESTING) [10] You have been provided with a Set ADT developed by a third party. This consists of a header file, set.h, defining the interface and the object file, coming soon (as a zip file), compiled for use in our Mac lab. You must implement a complete unit test suite to validate all functionality defined in the header file.

Requirements and Notes Hand in your main.c file (containing your test suite implementation) and a Makefile to compile your code and link it with set.o. You will be provided with, at least, two different object file implementations of Set. Include a report (in your README file) for each object file, indicating whether they passed your tests or not. If an object file didn’t pass your tests include all failure conditions that must be addressed in the README. If, at any time, the code crashes then the problem is with your code. An object file may provide you with erroneous results but will never cause your program to fail outright.

The test framework from question 1 should serve as a good foundation upon which to build the test framework for this question.