% testVerticalDist.m   test Verticaldist.m
% Caitlin Pretz for CISC106, sect 80, 10/10/2007

% Test formula to calculate the distance of a falling object in meters given falling
% time and initial velocity


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

% tolerance is "how far away from the expected value" the result
% is allowed to be.  Since the calculation involves a square root,
% not all inputs will produce results that can be represented exactly.

tolerance = 0.001;

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

% Test 1


actual = VerticalDist(5,3);
expected = 137.5;

diff = abs(expected-actual);

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

% Test 2

actual = verticalDist(6,2);
expected = 188.4;

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 testVerticalDist.m






