% testMyMin.m   Run regression tests on myMin.m 
% P. Conrad CISC106 Fall 2006

% See http://en.wikipedia.org/wiki/Regression_testing for
% explanation of "regression testing".


% test whether min works on a row vector

fprintf('Test 1...');
if (myMin([3 4 1 7 -2 9])==-2)
  fprintf('passed\n');
else  
  fprintf('failed\n');
end;

% test whether min works on a column vector with duplicates

fprintf('Test 2...');
if (myMin([3 2 6 2 9]')==2)
  fprintf('passed\n');
else  
  fprintf('failed\n');
end;

% test whether min works on a vector containing a single element

fprintf('Test 3...');
if (myMin([3])==3)
  fprintf('passed\n');
else  
  fprintf('failed\n');
end;

% test whether min returns an empty vector when passed an empty vector

fprintf('Test 4...');
if ( length(myMin([])) == 0) 
  fprintf('passed\n');
else  
  fprintf('failed\n');
end;

% test whether min works when min is last element 

fprintf('Test 5...');
if (myMin([5 4 3 2 1])==1)
  fprintf('passed\n');
else  
  fprintf('failed\n');
end;
