from
MATLAB/Simulink Unit Test Framework
by Carl Kritzinger
A unit test framework for matlab and simulink components
|
| make_unit_test_case(...
|
function test = make_unit_test_case(...
inputs,...
outputs,...
comparator,...
tolerance)
% make_unit_test_case - make a unit test case structure
%
% Inputs:
%
% inputs - input vectors for this test case
% oputputs - expected output vectors for this test case
% comparator - comparison operator to use to compare output and expected
% output vectors
% tolerance - not always relevant : comparator error tolerance
%
% Example:
% make_unit_test_case({[1 2 3],[1 2 3]},{[1 2 3]+[1 2 3]},'exactly equal')
%
% Other m-files required: none
%
% See also: unit_test, run_unit_test_batch, make_simulink_unit_test
% Author: Carl Kritzinger
% KAT DSP Team
% email address: carl@ska.ac.za
% November 2005
%------------- MAIN --------------
%default tolerance
if nargin == 3
tolerance = 1e-10;
end
%set up input vectors
for kk = 1:length(inputs)
temp.signals.values = inputs{kk};
temp.signals.dimensions = 1;
temp.time = [0:length(temp.signals.values)-1];
test.inputs{kk} = temp;
end
%set up output vectors
for kk = 1:length(outputs)
temp.signals.values = outputs{kk};
temp.signals.dimensions = 1;
temp.time = [0:length(temp.signals.values)-1];
test.expected_outputs{kk} = temp;
end
%miscellaneous info
test.simulation_time = length(temp.signals.values)-1;
test.comparator = comparator;
test.tolerance = tolerance;
test.unhandled_error = '';
|
|
Contact us at files@mathworks.com