function OK = struct2arg_test(S)
%struct2arg_test tets for struct2arg
%
%See also struct2arg

% test for scalar structure
s.category = 'tree';
s.height   = 37.4;
s.name     = 'birch';

args = struct2arg(s);
s2   = struct(args{:});
OK = isequalwithequalnans(s, s2);

% test for multidimensional structure
s3 = repmat(s, [2 30 4]);
% change height field for all elements into a random number to make each
% structure element unique
for i = 1:numel(s3)
    s3(i).height = rand*10 + 30;
end
args = struct2arg(s3);
s4   = struct(args{:});
OK(end+1) = isequalwithequalnans(s3, s4);


