% testAreaOfPizza.m   test areaOfPizza.m
% P. Conrad for CISC106, sect 99, 09/03/2007

%%%%%%%%%%%%%%%%%%%%%%%%
% define the tolerance %
%%%%%%%%%%%%%%%%%%%%%%%%

% tolerance is "how far away from the expected value" the result
% is allowed to be.  We have to have some tolerance because the
% calculation involves pi, which is always a approximation.

tolerance = 0.01;

%%%%%%%%%%%%%%%%%
% Run the tests %
%%%%%%%%%%%%%%%%%

% Test 1

expected = 113.10;
actual = areaOfPizza(12);
diff = abs(expected-actual);

if (diff < tolerance)
  disp('test 1 passed');
else
  disp('test 1 failed');
  expected
  actual
end
  

% Test 2

expected = 201.06;
actual = areaOfPizza(16);
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