瀏覽代碼

Generated C++ tests for StatemachineActive tests

Axel Terfloth 10 年之前
父節點
當前提交
91711ad1c5

+ 19 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/StatechartActiveTest/StatechartActive.sgen

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

+ 44 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/StatechartActiveTest/StatechartActiveTest.cc

@@ -0,0 +1,44 @@
+/**
+* Copyright (c) 2015 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 "StatechartActive.h"
+
+TEST(StatemachineTest, inactiveBeforeEnter) {
+	StatechartActive* statechart = new StatechartActive();
+	statechart->init();
+	EXPECT_TRUE(false);
+	delete statechart;
+}
+TEST(StatemachineTest, activeAfterEnter) {
+	StatechartActive* statechart = new StatechartActive();
+	statechart->init();
+	statechart->enter();
+	EXPECT_TRUE(false);
+	delete statechart;
+}
+TEST(StatemachineTest, inactiveAfterExit) {
+	StatechartActive* statechart = new StatechartActive();
+	statechart->init();
+	statechart->enter();
+	statechart->exit();
+	EXPECT_TRUE(false);
+	delete statechart;
+}
+TEST(StatemachineTest, activeAfterReenter) {
+	StatechartActive* statechart = new StatechartActive();
+	statechart->init();
+	statechart->enter();
+	statechart->exit();
+	statechart->enter();
+	EXPECT_TRUE(false);
+	delete statechart;
+}

+ 24 - 0
test-plugins/org.yakindu.sct.generator.cpp.test/model/test.sgen

@@ -1035,6 +1035,30 @@ GeneratorModel for sctunit::cpp {
 		}		
 	}
 	
+	test StatechartActive {
+		
+		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
+		}		
+	}
+	
 	test StatechartLocalReactions{
 		
 		feature Outlet{ 

+ 4 - 4
test-plugins/org.yakindu.sct.generator.cpp.test/test-gen/org/yakindu/sct/generator/cpp/test/AllTestsTest.java

@@ -32,10 +32,10 @@ import org.junit.runners.Suite.SuiteClasses;
 		ParenthesisTest.class, PriorityValuesTest.class, RaiseEventTest.class,
 		SameNameDifferentRegionTest.class, ShallowHistoryTest.class,
 		ShallowHistoryWithDeepEntryTest.class, SimpleEventTest.class,
-		StatechartLocalReactionsTest.class, SimpleHierachyTest.class,
-		StateIsActiveTest.class, StaticChoiceTest.class,
-		STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class,
-		SyncForkTest.class, SyncJoinTest.class,
+		SimpleHierachyTest.class, StatechartActiveTest.class,
+		StatechartLocalReactionsTest.class, StateIsActiveTest.class,
+		StaticChoiceTest.class, STextKeywordsInStatesAndRegionsTest.class,
+		StringExpressionsTest.class, SyncForkTest.class, SyncJoinTest.class,
 		TransitionWithoutConditionTest.class,
 		TriggerGuardExpressionsTest.class, ValuedEventsTest.class})
 public class AllTestsTest {

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

@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2015 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/StatechartActiveTest/StatechartActiveTest.cc", program = "gtests/StatechartActiveTest/StatechartActive", model = "testmodels/SCTUnit/StatechartActive.sct")
+@RunWith(GTestRunner.class)
+public class StatechartActiveTest {
+
+	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();
+	}
+}