function testresult = corner2center1_test
%corner2center1_test unit test for corner2center1
%
%See also: corner2center1

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2006-2011 Delft University of Technology
%       Gerben J. de Boer
%
%       g.j.deboer@tudelft.nl	
%
%       Fluid Mechanics Section
%       Faculty of Civil Engineering and Geosciences
%       PO Box 5048
%       2600 GA Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 of the License, or (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------
%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

xcor(:,:,1)   = [2 4 6 8; 10 12 14 16; 18 20 22 24; 26 28 30 32; 34 36 38 40];
xcor(:,:,2)   = xcor(:,:,1)+100;
xcor(:,:,3)   = xcor(:,:,1)+200;
xcor(:,:,:,2) = xcor + 1e3;

xcen1 = corner2center1(xcor,1);
xcen2 = corner2center1(xcor,2);
xcen3 = corner2center1(xcor,3);
xcen4 = corner2center1(xcor,4);

ans1(:,:,1)   = [6     8    10    12;    14    16    18    20;    22    24    26    28;    30    32    34    36];
ans1(:,:,2)   = ans1(:,:,1)+100;
ans1(:,:,3)   = ans1(:,:,1)+200;
ans1(:,:,:,2) = ans1 + 1e3;

ans2(:,:,1)   = [3 5 7; 11 13 15; 19 21 23; 27 29 31; 35 37 39];
ans2(:,:,2)   = ans2(:,:,1)+100;
ans2(:,:,3)   = ans2(:,:,1)+200;
ans2(:,:,:,2) = ans2 + 1e3;

ans3(:,:,1)   = [2 4 6 8; 10 12 14 16; 18 20 22 24; 26 28 30 32; 34 36 38 40];
ans3(:,:,1)   = ans3(:,:,1)+50;

ans3(:,:,2)   = ans3(:,:,1)+100;
ans3(:,:,:,2) = ans3 + 1e3;

ans4(:,:,1)   = [2 4 6 8; 10 12 14 16; 18 20 22 24; 26 28 30 32; 34 36 38 40];
ans4(:,:,1)   = ans4(:,:,1)+500;

ans4(:,:,2)   = ans4(:,:,1)+100;
ans4(:,:,3)   = ans4(:,:,1)+200;

 OK(1) = isequal(ans1,xcen1);
 OK(2) = isequal(ans2,xcen2);
 OK(3) = isequal(ans3,xcen3);
 OK(4) = isequal(ans4,xcen4);
 OK(5) = isequal([0 2 4],corner2center1([-1 1 3 5]));
 
 testresult = all(OK);