// testFtoC.js        test script for FtoC() function
// P. Conrad for CISC103, sect 99, 10/23/2007

// test the function FtoC()
function testFtoC() {

  //=======================================
  // define the tolerance 
  //=======================================
  
  // tolerance is "how far away from the expected value" the result
  // is allowed to be.  Since this calculation involves only simple
  // arithmetic, we can have a very small tolerance (i.e. expect a 
  // very accurate answer

  var tolerance = 0.00001;

  //===================
  //  Run the tests 
  //=================== 

  //  Test 1

  var expected = 20
  var actual = FtoC(68); // convert 68 degrees Fahrenheit to Celsius
  var diff = Math.abs(expected-actual);

  if (diff < tolerance) 
    {
      print('test 1 passed');
    }
  else 
    {
      print('test 1 failed');
      print("expected=" + expected);
      print("actual=" + actual);
    }

  //  Test 2

  expected = 30
  actual = FtoC(86); // convert 86 degrees fahrenheit to celsius
  diff = Math.abs(expected-actual);

  if (diff < tolerance) 
    {
      print('test 2 passed');
    }
  else 
    {
      print('test 2 failed');
      print("expected=" + expected);
      print("actual=" + actual);
    }

} // function testFtoC

