// test03.cxx -- John Valois (valoisj@cs.rpi.edu)

// Test case to check copy constructor, assignment, and comparison.


#include <iostream>
#include "stack.h"

using std::cout;
using std::endl;


int main()
{
  cout << "test03: copy, assignment, and comparison... ";
  try 
  {
    stack<int> s1;
    int i;
    for (i=0; i < s1.max_size(); ++ i)
      s1.push(i);

    stack<int> s2(s1);
    for (i=s1.max_size() - 1; i >= 0; --i)
    {
      if (s2.top() != i)
      {
	cout << "FAILED (copy constructor)" << endl;
	return 1;
      }
      s2.pop();
    }

    s2 = s1;
    for (i=s1.max_size() - 1; i >= 0; --i)
    {
      if (s2.top() != i)
      {
	cout << "FAILED (assignment)" << endl;
	return 1;
      }
      s2.pop();
    }

    s2 = s1;
    if (s1 != s2)
    {
      cout << "FAILED (assignment)" << endl;
      return 1;
    }
  }
  catch (...) 
  {
    cout << "FAILED (threw exception)" << endl;
    return 1;
  }

  cout << "PASSED" << endl;
  return 0;
}
