Andreas Mülder 10 лет назад
Родитель
Сommit
0dfad67bd7

+ 3 - 3
test-plugins/org.yakindu.sct.generator.c.test/gtests/CKeywords/CKeywords.cc

@@ -21,9 +21,9 @@ TEST(StatemachineTest, CKeywordsTest) {
 	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_char));
 	cKeywordsIface_raise_auto(&handle);
 	cKeywords_runCycle(&handle);
-	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_const));
-	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_const_switch_case));
-	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_const_switch_case_enum_asm));
+	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_loop));
+	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_loop_switch_case));
+	EXPECT_TRUE(cKeywords_isActive(&handle, CKeywords_auto_loop_switch_case_enum_asm));
 }
 
 		

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

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

+ 30 - 0
test-plugins/org.yakindu.sct.generator.c.test/gtests/ConstantsTests/ConstantsTests.cc

@@ -0,0 +1,30 @@
+/**
+* Copyright (c) 2014 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 "Constants.h"
+
+
+Constants handle;
+
+TEST(StatemachineTest, constantDefinition) {
+	constants_init(&handle);
+	constants_enter(&handle);
+	EXPECT_TRUE(constants_isActive(&handle, Constants_main_region_A));
+	EXPECT_TRUE(constantsIface_get_x(&handle) == 10);
+	EXPECT_TRUE(constantsIface_get_y(&handle) == 20);
+	EXPECT_TRUE(strcmp(constantsIfaceNamed_get_y(&handle) , "Hello World") == 0);
+	constantsIface_raise_e(&handle);
+	constants_runCycle(&handle);
+	EXPECT_TRUE(constantsIface_get_result(&handle) == 20);
+}
+
+		

+ 12 - 0
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen

@@ -109,6 +109,18 @@ GeneratorModel for sctunit::c {
 		}			
 	}
 	
+	test ConstantsTests {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.c.test" 
+			targetFolder = "test-gen"			
+		}		
+				
+		feature JUnitWrapper {
+			WrapToJUnit =  "true" 
+		}			
+	}
+	
 	test Declarations{
 		
 		feature Outlet{ 

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

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