Commit 9c8069c3 authored by Ludwig Dickmanns's avatar Ludwig Dickmanns
Browse files

MCDC:

* MCDCUtils: added FormalRequitementMCDC
* McdcTestSuiteGenerator: started implementation


Issue-Ref: 3476
Issue-Url: https://af3-developer.fortiss.org/issues/3476

Signed-off-by: Ludwig Dickmanns's avatarLudwig Dickmanns <dickmanns@fortiss.org>
parent f2d9d559
......@@ -35,6 +35,7 @@ import org.fortiss.af3.expression.model.terms.IntConst;
import org.fortiss.af3.expression.model.terms.PredefinedFunction;
import org.fortiss.af3.expression.model.terms.Var;
import org.fortiss.af3.expression.model.terms.imperative.Assignment;
import org.fortiss.af3.expression.model.terms.imperative.IStatementTerm;
import org.fortiss.af3.expression.model.types.TBool;
import org.fortiss.af3.expression.model.types.TDouble;
import org.fortiss.af3.expression.model.types.TInt;
......@@ -124,6 +125,19 @@ public final class MCDCUtils {
}
return null;
}
if(term instanceof FormalRequirementMCDC) {
FormalRequirementMCDC formalRequirementMCDC = (FormalRequirementMCDC)term;
BoolExpr guard = (BoolExpr)toZ3(prefix, ctx, formalRequirementMCDC.getGuard(), context);
BoolExpr thenE = ctx.mkTrue();
BoolExpr elseE = ctx.mkTrue();
for(IStatementTerm statement : formalRequirementMCDC.getThenBlock().getStatements()) {
thenE = ctx.mkAnd(thenE, (BoolExpr)toZ3(prefix, ctx, statement, context));
}
for(IStatementTerm statement : formalRequirementMCDC.getElseBlock().getStatements()) {
elseE = ctx.mkAnd(elseE, (BoolExpr)toZ3(prefix, ctx, statement, context));
}
return ctx.mkOr(ctx.mkAnd(guard, thenE), ctx.mkAnd(ctx.mkNot(guard), elseE));
}
return null;
}
......
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.testing.mcdc.generator;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestSuite;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.testing.extension.ITestSuiteGenerator;
import org.fortiss.af3.testing.extension.data.TestSuiteGenerationException;
import org.fortiss.af3.testing.model.TestCase;
import org.fortiss.af3.testing.model.TestSuite;
import org.fortiss.af3.testing.model.TestSuiteSpecification;
import org.fortiss.af3.testing.model.mcdc.FormalRequirementMCDC;
import org.fortiss.af3.testing.model.mcdc.McdcSpecificationPart;
/**
*
* @author ludwig
*/
public class McdcTestSuiteGenerator implements ITestSuiteGenerator {
private TestSuite initialSuite;
/**
* Constructor.
*
* @param initialSuite
*/
public McdcTestSuiteGenerator(TestSuite initialSuite) {
this.initialSuite = initialSuite;
}
/** {@inheritDoc} */
@Override
public TestSuite generate(TestSuiteSpecification specification, IProgressMonitor monitor)
throws TestSuiteGenerationException, InterruptedException {
McdcSpecificationPart spec =
pickFirstInstanceOf(McdcSpecificationPart.class, specification.getSpecifications());
TestSuite testSuite = createTestSuite("McdcTestSuite", spec.getTestSuiteSpecification());
testSuite.setGeneratedBy(getClass());
FormalRequirementMCDC req = spec.getFormalRequirementMCDC();
EList<TestCase> initialTCs = initialSuite.getTestCases();
if(initialTCs != null && !initialTCs.isEmpty()) {
for(TestCase testCase : initialTCs) {
}
}
return null;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment