Browse Source

Created c generator test case for statemachine keywords.

Markus Mühlbrandt 9 years ago
parent
commit
a58533c938

+ 19 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StatemachineKeywords/StatechartKeywords.sgen

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

+ 33 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StatemachineKeywords/StatemachineKeywords.cc

@@ -0,0 +1,33 @@
+/**
+* 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"
+#include "StatechartKeywordsRequired.h"
+
+
+StatechartKeywords handle;
+
+TEST(StatemachineTest, statemachineKeywords) {
+	statechartKeywords_init(&handle);
+	statechartKeywords_enter(&handle);
+	EXPECT_TRUE(statechartKeywords_isStateActive(&handle, StatechartKeywords_main_region_Timer));
+}
+
+		
+void statemachineKeywords_setTimer(const sc_eventid evid, const sc_integer time_ms, const sc_boolean periodic){
+	// Mockup
+	statemachineKeywords_raiseTimeEvent(&handle, evid);
+}
+
+void statemachineKeywords_unsetTimer(const sc_eventid evid){
+	// Mockup
+}		

File diff suppressed because it is too large
+ 729 - 708
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen


+ 5 - 5
test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java

@@ -15,11 +15,11 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({AlwaysOncycle.class, AssignmentAsExpression.class, BitExpressions.class, BooleanExpressions.class,
-		CastExpressions.class, Choice.class, CKeywords.class, ConditionalExpression.class, ConstantsTests.class,
-		Declarations.class, DeepEntry.class, DeepHistory.class, DynamicChoice.class, EmptyTransition.class,
-		EnterState.class, EntryChoice.class, EntryExitSelfTransition.class, EntryReactionAction.class,
-		ExitOnSelfTransition.class, ExitState.class, FeatureCalls.class, FinalState.class, Guard.class,
-		GuardedEntry.class, GuardedExit.class, HistoryWithExitPoint.class, HistoryWithoutInitialStep.class,
+		CastExpressions.class, Choice.class, CKeywords.class, StatemachineKeywords.class, ConditionalExpression.class,
+		ConstantsTests.class, Declarations.class, DeepEntry.class, DeepHistory.class, DynamicChoice.class,
+		EmptyTransition.class, EnterState.class, EntryChoice.class, EntryExitSelfTransition.class,
+		EntryReactionAction.class, ExitOnSelfTransition.class, ExitState.class, FeatureCalls.class, FinalState.class,
+		Guard.class, GuardedEntry.class, GuardedExit.class, HistoryWithExitPoint.class, HistoryWithoutInitialStep.class,
 		InEventLifeCycle.class, IntegerExpressions.class, InternalEventLifeCycle.class, LocalReactions.class,
 		LogicalAndTests.class, LogicalOrTests.class, NamedInterfaceAccess.class, OutEventLifeCycle.class,
 		Parenthesis.class, PriorityValues.class, RaiseEvent.class, ReadOnlyVariable.class,

+ 39 - 0
test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/StatemachineKeywords.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.c.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/StatemachineKeywords/StatemachineKeywords.cc", program = "gtests/StatemachineKeywords/StatechartKeywords", model = "testmodels/SCTUnit/StatechartKeywords.sct")
+@RunWith(GTestRunner.class)
+public class StatemachineKeywords {
+
+	protected final GTestHelper helper = new GTestHelper(this) {
+
+		@Override
+		protected void getSourceFiles(Collection<String> files) {
+			super.getSourceFiles(files);
+			files.add(getFileName(getTestProgram()) + ".c");
+		}
+	};
+
+	@Before
+	public void setUp() {
+		helper.generate();
+		helper.compile();
+	}
+}

+ 1 - 0
test-plugins/org.yakindu.sct.test.models/tests/AllTests.sctunit

@@ -6,6 +6,7 @@ testsuite AllTests {
 	CastExpressions,
 	Choice, 
 	CKeywords,
+	StatemachineKeywords,
 	ConditionalExpression,
 	ConstantsTests,
 	Declarations, 

+ 9 - 0
test-plugins/org.yakindu.sct.test.models/tests/StatemachineKeywords.sctunit

@@ -0,0 +1,9 @@
+
+testgroup StatemachineKeywords for statechart StatechartKeywords {
+	test statemachineKeywords { 
+		enter
+		assert active(StatechartKeywords.main_region.Timer) 
+		 
+	} 
+}
+