Explorar o código

added: StringExpressions.java, GuardTest.java

Andreas Mülder %!s(int64=13) %!d(string=hai) anos
pai
achega
379b94502b

+ 26 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StringExpressions/StringExpressions.cc

@@ -0,0 +1,26 @@
+/**
+* Copyright (c) 2012 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 "gtest/gtest.h"
+#include "StringExpressions.h"
+
+TEST(StatemachineTest, StringExpressionsTest) {
+	StringExpressions handle;
+	stringExpressions_init(&handle);
+	stringExpressions_enter(&handle);
+	EXPECT_TRUE(stringExpressions_isActive(&handle, StringExpressions_main_region_StateA));
+	EXPECT_TRUE(stringExpressionsIface_get_myString(&handle).equals("hello"));
+	EXPECT_TRUE(stringExpressionsIface_get_myString2(&handle).equals("world"));
+	stringExpressionsIface_raise_e1(&handle);
+	stringExpressions_runCycle(&handle);
+	EXPECT_TRUE(stringExpressions_isActive(&handle, StringExpressions_main_region_StateB));
+	EXPECT_TRUE(stringExpressionsIface_get_equals(&handle) == false);
+	EXPECT_TRUE(stringExpressionsIface_get_notEqual(&handle) == true);
+}

+ 8 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/StringExpressions/StringExpressions.sgen

@@ -0,0 +1,8 @@
+GeneratorModel for yakindu::c {
+	statechart StringExpressions {
+		feature Outlet {
+			targetProject = "gtests"
+			targetFolder = "StringExpressions"
+		}
+	}
+}

+ 39 - 0
test-plugins/org.yakindu.sct.generator.c.test/src-gen/org/yakindu/sct/generator/c/test/StringExpressions.java

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

+ 58 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/sct/generator/java/test/GuardTest.java

@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2012 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.java.test;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.yakindu.scr.guard.GuardStatemachine;
+import org.yakindu.scr.guard.GuardStatemachine.State;
+/**
+ *  Unit TestCase for Guard
+ */
+@SuppressWarnings("all")
+public class GuardTest {
+
+	private GuardStatemachine statemachine;
+
+	@Before
+	public void setUp() {
+		statemachine = new GuardStatemachine();
+		statemachine.init();
+		statemachine.enter();
+	}
+
+	@After
+	public void tearDown() {
+		statemachine = null;
+	}
+
+	@Test
+	public void testguardTest() {
+		assertTrue(statemachine.isStateActive(State.Main_region_A));
+		statemachine.raiseEvent1();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_A));
+		statemachine.raiseEvent2();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_B));
+		statemachine.raiseReturn();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_A));
+		statemachine.raiseEvent1();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_B));
+		statemachine.raiseReturn();
+		statemachine.runCycle();
+		assertTrue(statemachine.isStateActive(State.Main_region_A));
+	}
+}