% testAvgAcc.m   test avgAcc.m
% Jimmy Mandala forISC106, sect 10A, 09/18/2007

% Test formula to calculate the average acceleration of an object 

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

% tolerance is "how far away from the expected value" the result
% is allowed to be.  

tolerance = 0.0001;

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

% Test 1


actual = avgAcc (100,200,1,5);
expected = 25;

diff = abs(expected-actual);

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

% Test 2

actual = avgAcc(300, 200, 1, 3);
expected = -50;

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

