www.gusucode.com > sldv工具箱matlab源码程序 > sldv/sldv/private/reduceTestCases.m
function reduceTestCases(testComp) % Copyright 2007-2011 The MathWorks, Inc. as = testComp.activeSettings; if strcmp(as.Mode, 'TestGeneration') && ~isempty(testComp.testCases) if strcmp(as.TestSuiteOptimization, 'IndividualObjectives') % Individual objectives: we remove test cases % satisfying objectives that have already been satisfied % this can happen when loading existing test cases allTestCases = testComp.testCases; propIdsArray = testComp.getPropDvIdsArray; [~,col] = size(propIdsArray); assert(col==2); testCaseCnt = length(allTestCases); goalTcMap = containers.Map('KeyType', 'double', 'ValueType', 'double'); for i=1:testCaseCnt if length(allTestCases(i).goals) == 1 propId = allTestCases(i).goals.getGoalMapId; res = propIdsArray(propIdsArray(:,1) == propId, :); id = res(:,2); if goalTcMap.isKey(id) connect(allTestCases(goalTcMap(id)), allTestCases(i), 'up'); else goalTcMap(id) = i; end end end else allTestCases = testComp.testCases; testCaseCnt = length(allTestCases); if testCaseCnt>0 tcLengths = ones(1,testCaseCnt); for idx=1:testCaseCnt tcLengths(idx) = allTestCases(idx).length; end [~,sortIdx] = sort(tcLengths); allTestCases = allTestCases(sortIdx); testComp.firstTestCase = allTestCases(1); connect(testComp.firstTestCase, testComp,'up'); for idx = 2:testCaseCnt allTestCases(idx).insertInTree(testComp.firstTestCase); end update_leaf_testcases(testComp.firstTestCase); end end end end function update_leaf_testcases(tcUdi) firstIter = true; containedTcs = []; while true while ~isempty(tcUdi.down) if isempty(containedTcs) containedTcs = tcUdi; else containedTcs(end+1) = tcUdi; %#ok<AGROW> end tcUdi = tcUdi.down; end if firstIter tcUdi.leafTestCase = tcUdi; firstIter = false; end for tc = containedTcs tc.leafTestCase = tcUdi; end containedTcs = []; if ~isempty(tcUdi.right) tcUdi = tcUdi.right; else break; end end end