%TEST_RM2MAT runs unit tests for the RM2MAT function.
% $Source: /home/stpierre/cvsroot/matlab/simulink/matrix/test/test_rm2mat.m,v $
% $Revision: 1.2 $
% $Date: 2009-07-19 22:03:27 $
% Copyright (c) 2000-2009, Jay A. St. Pierre. All rights reserved.
test_title = 'rm2mat';
disp_test_title(test_title);
failures=0;
disp_test_name('Insufficient Arguments');
expected_err = 'rm2mat() requires at least one input argument';
fct_call = 'rm2mat';
failures=failures+check_err(fct_call, expected_err);
disp_test_name('Too Many Array Dimensions');
expected_err = ['Input must be a vector or a matrix, not a higher order' ...
' array'];
too_big=ones(2,2,2), disp(' ')
fct_call = 'rm2mat(too_big)';
failures=failures+check_err(fct_call, expected_err);
disp_test_name('Non-square matrices');
expected_err = ...
['Number of columns of input must be a square of an integer,', ...
10, 'or you must specify the number of columns you want the' ...
10, 'output matrices to have.'];
fct_call='rm2mat([1 2 3])';
failures=failures+check_err(fct_call, expected_err);
disp_test_name('Incompatible matrix size parameter');
expected_err = 'Number of columns of input is not evenly divisble by 4';
fct_call='rm2mat([1 2 3 4 5 6], 4)';
failures=failures+check_err(fct_call, expected_err);
disp_test_name('Using rm2mat on a vector');
expected_warn = 'You may want to use PERMUTE instead of rm2mat';
fct_call='rm2mat([1 2 3 4 5 6], 6);';
failures=failures+check_warn(fct_call, expected_warn);
disp_test_name('Single vector input, no column spec');
truth_value = '[1 2; 3 4]';
test_value = 'rm2mat([1 2 3 4])';
failures=failures+check_value(truth_value, test_value);
disp_test_name('Single vector input, with column spec');
truth_value = '[1 2; 3 4; 5 6]';
test_value = 'rm2mat([1 2 3 4 5 6], 2)';
failures=failures+check_value(truth_value, test_value);
disp_test_name('2-D array input, no column spec');
A=[1 2; 3 4]; A(:,:,2)=[5 6; 7 8], disp(' ')
truth_value = 'A';
test_value = 'rm2mat([1 2 3 4; 5 6 7 8])';
failures=failures+check_value(truth_value, test_value);
disp_test_name('2-D array input, column spec');
A=[1 2 3; 4 5 6]; A(:,:,2)=2*A, disp(' ')
truth_value = 'A';
test_value = 'rm2mat([1 2 3 4 5 6; 2 4 6 8 10 12], 3)';
failures=failures+check_value(truth_value, test_value);
disp_num_failures(test_title, failures)