Bläddra i källkod

Added Testcase for statechart keywords.

Markus Mühlbrandt 9 år sedan
förälder
incheckning
077b1a832d

+ 19 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/StatemachineKeywordsTest/StatechartKeywords.sgen

@@ -0,0 +1,19 @@
+GeneratorModel for yakindu::cpp {
+	statechart StatechartKeywords {
+		feature Outlet {
+			targetProject = "gtests"
+			targetFolder = "StatemachineKeywordsTest"
+		}
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineEnterSequences = false 
+			inlineExitActions = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEntries = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+		}
+	}
+}

+ 21 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/StatemachineKeywordsTest/StatemachineKeywordsTest.cc

@@ -0,0 +1,21 @@
+/**
+* Copyright (c) 2016 committers of YAKINDU and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*     committers of YAKINDU - initial API and implementation
+*/
+#include <string>
+#include "gtest/gtest.h"
+#include "StatechartKeywords.h"
+
+TEST(StatemachineTest, statemachineKeywords) {
+	StatechartKeywords* statechart = new StatechartKeywords();
+	statechart->init();
+	statechart->enter();
+	EXPECT_TRUE(statechart->isStateActive(StatechartKeywords::main_region_Timer));
+	delete statechart;
+}

+ 26 - 2
test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen

@@ -1395,7 +1395,7 @@ GeneratorModel for sctunit::cpp {
 		}		
 	}	
 
-	test ValuedEvents{
+	test ValuedEvents {
 		
 		feature Outlet{ 
 			targetProject = "org.yakindu.sct.generator.cpp.test" 
@@ -1417,5 +1417,29 @@ GeneratorModel for sctunit::cpp {
 			inlineExitRegion = false
 			inlineEntries = false
 		}	
-	}	
+	}
+	
+	test StatemachineKeywords {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.cpp.test" 
+			targetFolder = "test-gen"			
+		}		
+		
+		feature JUnitWrapper {
+			WrapToJUnit =  "true"
+		}				
+				
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}	
+	}
 }

+ 39 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/test-gen/org/yakindu/sct/generator/cpp/test/StatemachineKeywordsTest.java

@@ -0,0 +1,39 @@
+/**
+* Copyright (c) 2016 committers of YAKINDU and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+*     committers of YAKINDU - initial API and implementation
+*/
+package org.yakindu.sct.generator.cpp.test;
+
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.yakindu.sct.generator.c.gtest.GTest;
+import org.yakindu.sct.generator.c.gtest.GTestRunner;
+import org.yakindu.sct.generator.c.gtest.GTestHelper;
+
+@GTest(sourceFile = "gtests/StatemachineKeywordsTest/StatemachineKeywordsTest.cc", program = "gtests/StatemachineKeywordsTest/StatechartKeywords", model = "testmodels/SCTUnit/StatechartKeywords.sct")
+@RunWith(GTestRunner.class)
+public class StatemachineKeywordsTest {
+
+	protected final GTestHelper helper = new GTestHelper(this) {
+
+		@Override
+		protected void getSourceFiles(Collection<String> files) {
+			super.getSourceFiles(files);
+			files.add(getFileName(getTestProgram()) + ".cpp");
+		}
+	};
+
+	@Before
+	public void setUp() {
+		helper.generate();
+		helper.compile();
+	}
+}

+ 5 - 3
test-plugins/org.yakindu.sct.test.models/tests/AllTests.sctunit

@@ -6,7 +6,6 @@ testsuite AllTests {
 	CastExpressions,
 	Choice, 
 	CKeywords,
-	StatemachineKeywords,
 	ConditionalExpression,
 	ConstantsTests,
 	Declarations, 
@@ -49,13 +48,16 @@ testsuite AllTests {
 	StatechartLocalReactions,
 	StateIsActive, 
 	StaticChoice,
-	STextKeywordsInStatesAndRegions, 
+	STextKeywordsInStatesAndRegions,
 	StringExpressions, 
 	SyncFork,
 	SyncJoin,
-	TimedTransitions,
 	TransitionWithoutCondition,
 	TriggerGuardExpressions,
 	TriggerExpressionPrecedence,
 	ValuedEvents
+	//Add the following tests if sct unit Java and C++ generators
+	// support mock timer service generation
+	//StatemachineKeywords,
+	//TimedTransitions,
 }