% testAreaOfRectPizza.m   test areaOfPizza.m
% M. Haggerty for CISC105, sect 99, 09/03/2007

%%%%%%%%%%%%%%%%%%%%%%%%
% define the tolerance %
%%%%%%%%%%%%%%%%%%%%%%%%

% tolerance is "how far away from the expected value" the result
% is allowed to be.  Here, we can have a very small tolerance,
% because the values should be almost exact.

tolerance = 0.00001;

%%%%%%%%%%%%%%%%%
% Run the tests %
%%%%%%%%%%%%%%%%%

% Test 1

expected = 120;
actual = areaOfRectPizza(10,12);
diff = abs(expected-actual);

if (diff < tolerance)
  disp('test 1 passed');
else
  disp('test 1 failed');
  expected
  actual
end
  

% Test 2

expected = 169;
actual = areaOfRectPizza(13,13);
diff = abs(expected-actual);

if (diff < tolerance)
  disp('test 2 passed');
else
  % signal that test failed, and print both expected and actual
  disp('test 2 failed');
  expected
  actual
end
  

% end testAreaOfPizza.m