Project Tester Class

ECE 250 students are not required to know this.

The heart of the the tester-driver testing environment for ECE 250 is the virtual class Tester. This class may be viewed here. This implements a simple command-line interpreter by means of the member function void run() which reads commands from console input and then interprets them appropriately. It may do so immediately or through the help of the member function void process().

The tester class has two class members:

Type *object
The object being tested (by default the 0 pointer).
string command
The current command read by the interpreter.

There are two global variables which are also used for tracking. These cannot be static members as they must be shared by all instances of derived classes of Tester. These are stored within the dwharder/Algorithms_and_Data_Structures namespace.

int count
The current counter.
string history[101]
An array for tracking historical commands.

The void process() function is virtual and must be defined in any derived class of the tester class.

Type Being Tested (Constructor)

The constructor optionally takes one argument which is an instance of the object to be tested. If such an argument is not passed, then the object being tested is set to zeros and must be explicitly initialized as a result of a command provided by the user.

One command standard with any object is new which simply assigns:

object = new Type();

Organization

When the function void run() is executed, it begins reading standard input for a string. It does this in an infinite loop and only breaks out as a result of specific input. The sequence for the infinite loop is as follows:

  • Read console input,
  • Check for end-of-line character,
  • Check and update history,
  • Match the command against certain key commands, and
  • If the command is unrecognized, call void process().

Exiting

If the next character of console input is an end-of-file character, the test run ends: return;.

History

The command !! may be used by the user to mean the previous command, thus, if the user previously used push_front, the user could now use !! instead of typing the entire expression out again.

The command !N where N is an integer is interpreted as meaning use the Nth command, where N is any integer greater than or equal to 1 and less than the current command number.

Once any historical commands are interpreted, the current command is stored in the history.

Key Commands

The following key commands are recognized by run():

exit
End the test run: return;.
new
Create a new object to be tested: object = new Type();
delete
Delete the object being tested: delete object;
summary
Print out a summary of memory usage.
details
Print out the details of memory usage.

Calling void process()

If the command is not recognized as one of the above key commands, then the process() function is called. This must be defined within any derived class and calls member functions as appropriate to the class being tested. This command must indicate to the user if a command is not recognized.

The form of the member function void process() is described under Derived Tester Classes.