from
MATLAB/Simulink Unit Test Framework
by Carl Kritzinger
A unit test framework for matlab and simulink components
|
| matlab_unit_test(component,parameters,test_cases)
|
function [results] = matlab_unit_test(component,parameters,test_cases)
% matlab_unit_test - a hook to allow matlab functions to be integrated into the unit test framework. The function will intantiate the component, hook it up to the relevant inputs and outputs, run the simulation and save the results.
%
% Inputs:
% component - the component to be tested
% parameters - parameters used to set up the component
% test_cases - structure containing details of the unit test cases
%
% Outputs:
% results - structure containing the result of the testing.
%
% Example:
% [results] = matlab_unit_test(component,function_created_sub_system,parameters,test_cases)
%
% 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 --------------
results = [];
%iterate through the test cases
for jj = 1:length(test_cases)
current_test_case = test_cases(jj);
for kk = 1:length(current_test_case.inputs)
inputs{kk} = current_test_case.inputs{kk}.signals.values;
end
[outputs{1:length(current_test_case.expected_outputs)}] = feval(component,parameters{:},inputs{:});
for kk = 1:length(outputs)
current_test_case.outputs{kk} = outputs{kk};
end
results = [results current_test_case];
end
|
|
Contact us at files@mathworks.com