cantera/ext/matlab_xunit/+xunit/+utils/isTestCaseSubclass.m
Ray Speth bac65b26a1 Added machinery for unit testing of the Matlab toolbox
Unit tests are written using the Matlab xUnit Test Framework
2012-03-13 17:32:10 +00:00

39 lines
894 B
Matlab

function tf = isTestCaseSubclass(name)
%isTestCaseSubclass True for name of a TestCase subclass
% tf = isTestCaseSubclass(name) returns true if the string name is the name of
% a TestCase subclass on the MATLAB path.
% Steven L. Eddins
% Copyright 2008-2009 The MathWorks, Inc.
tf = false;
class_meta = meta.class.fromName(name);
if isempty(class_meta)
% Not the name of a class
return;
end
if strcmp(class_meta.Name, 'TestCase')
tf = true;
else
tf = isMetaTestCaseSubclass(class_meta);
end
function tf = isMetaTestCaseSubclass(class_meta)
tf = false;
if strcmp(class_meta.Name, 'TestCase')
tf = true;
else
% Invoke function recursively on parent classes.
super_classes = class_meta.SuperClasses;
for k = 1:numel(super_classes)
if isMetaTestCaseSubclass(super_classes{k})
tf = true;
break;
end
end
end