next up previous contents
Next: Testing the Insertion Agents: Up: Using Various SLLIST Objects: Previous: Testing the Delete Operator

Testing the Overloaded Equal:

This code fragment tests the overloaded equal operator when the list size for the object Quinn is smaller than the list size for the object Qaitlin.

 
  {
  int input[10] = {1,2,3,4,5,6,7,8,9,10};

  cout << "Instantiating List Qaitlin" << endl;
  INT_SLLIST Qaitlin("intQa4");

  cout << endl << "Building Qaitlin List" << endl;
  Qaitlin.build_list(input,10);
  cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
  cout << endl;
  cout << endl << "Qaitlin = " << endl << Qaitlin << endl;

  cout << endl << "Delete the element 11 " << endl;
  Qaitlin.delete_element(11);
  cout << endl << "Qaitlin = " << endl << Qaitlin << endl;

  int input2[6] = {10,20,30,40,50,60};

  cout << "Instantiating List Quinn" << endl;
  INT_SLLIST Quinn("intQu1");

  cout << endl << "Building Quinn List" << endl;
  Quinn.build_list(input2,6);
  cout << "Quinn has " << Quinn.get_number_elements() << " elements";
  cout << endl;
  cout << endl << "Quinn = " << endl << Quinn << endl;

  cout << endl << "Overloaded Equal Test: Quinn = Qaitlin" << endl;
  Quinn = Qaitlin;
  cout << endl << "Quinn = " << endl << Quinn << endl;
  }
  
  return 0;
}

The corresponding output is:

Instantiating List Qaitlin
In default SLLIST<intQa4> constructor.
Exit default SLLIST<intQa4> constructor.

Building Qaitlin List
In SLLIST<intQa4> build_list.
Exit SLLIST<intQa4> build_list.
Qaitlin has 10 elements

Qaitlin = 
1-->2-->3-->4-->5-->6-->7-->8-->9-->10.

Delete the element 11 

Qaitlin = 
1-->2-->3-->4-->5-->6-->7-->8-->9-->10.


Instantiating List Quinn
In default SLLIST<intQu1> constructor.
Exit default SLLIST<intQu1> constructor.

Building Quinn List
In SLLIST<intQu1> build_list.
Exit SLLIST<intQu1> build_list.
Quinn has 6 elements

Quinn = 
10-->20-->30-->40-->50-->60.

Overloaded Equal Test: Quinn = Qaitlin
In SLLIST<intQu1> overloaded =.
Exit SLLIST<intQu1> overloaded =.

Quinn = 
1-->2-->3-->4-->5-->6-->7-->8-->9-->10.

Entering SLLIST<intQu1> destructor.
     Removing SL_CELL -1
         Removing SL_CELL 0
             Removing SL_CELL 1
                 Removing SL_CELL 2
                     Removing SL_CELL 3
                         Removing SL_CELL 4
                             Removing SL_CELL 5
                                 Removing SL_CELL 6
                                     Removing SL_CELL 7
                                         Removing SL_CELL 8
Leaving SLLIST destructor.

Entering SLLIST<intQa4> destructor.
     Removing SL_CELL -1
         Removing SL_CELL 0
             Removing SL_CELL 1
                 Removing SL_CELL 2
                     Removing SL_CELL 3
                         Removing SL_CELL 4
                             Removing SL_CELL 5
                                 Removing SL_CELL 6
                                     Removing SL_CELL 7
                                         Removing SL_CELL 8
Leaving SLLIST destructor.



Jim Peterson
1999-04-22