// testSwap.cc P. Conrad for CISC181
// a testing driver for swap functions


#include <iostream>
using namespace std;
#include "swap.h"


bool approxEquals(double a, 
		  double b,
		  double tolerance = 1E-5)
{
  // fabs is "floating point absolute value
  // we want the abs value of the difference

  return ( fabs(a-b) < tolerance  );
}

// A longer version:
//
//  double difference = fabs(a-b);
//  if (difference < tolerance )
//    return true;
//  else
//    return false;



int main(void)
{
  int x=5; int y=6;


  swap(x,y);

  if (x==6 && y==5)
    cout << "Passed" << endl;
  else
    cout << "Failed" << endl;

  double w=5.1; double z=6.2;

  swap(w,z);

  // THIS WON'T WORK: if (w==6.2 && z==5.1)

  if (approxEquals(w,6.2) && approxEquals(z,5.1))
    cout << "Passed" << endl;
  else
    cout << "Failed" << endl;

      
  return 0;

}
