Homework 4, Exceptions and Testing.

Short Description:

Modify your program from Homework 2 to produce exceptions when the program is used incorrectly. Test this.

This assignment is worth 20 points.

Goals

When you finish this homework, you should have:

If you need a copy of DListT.cpp a semi-working version is provided.

Formal Description

  1. Modify your DListT::Delete() function to throw an out_of_range exception.

    The text should be "DListT::Delete: Attempt to delete from an empty list."

    Remove printing the error from your class code. Your list class should not print ANY messages when you are finished.

  2. Modify your DListT::Data() function so that it throws a custom exception when the user attempts to access data when the current pointer is not valid.

    Your exception should be derived from the logic_error class and should be called invalid_current.

    The text of the error should be "DListT::Data: Invalid data access attempt."

    Remove printing the error from your class code. Your list class should not print ANY messages when you are finished.

  3. Modify the test driver given
    1. Build a test case to test the InsertAfter
      • In the comments before this section describe, in detail, your test plan.
      • Implement this test plan in the test case.
    2. Build a test case to test each of your two exceptions. (There should be two distinct tests routines for this).
      • Make sure to test that the correct text is returned.
      • Make sure that the various parent exceptions are caught. (exception, logic_error, invalid_current)
Please be aware that I may test both your test driver or your modified DListT.

Required Files

A single tar file containing the source code and makefile for this program.

Submission

Submit the assignment to the D2L folder Homework 4 by the due date.