Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuergen Haug2019-04-15 13:00:47 -0400
committerJuergen Haug2019-04-15 13:03:58 -0400
commit636465baf602e2bc9ea0b6ae89c2bb255306eaaf (patch)
tree82a2822a601acf79e3672df256f237e4051c5dae /tests
parentc4fc914e0870f96b996033a92ba515d54c21da0c (diff)
downloadorg.eclipse.etrice-636465baf602e2bc9ea0b6ae89c2bb255306eaaf.tar.gz
org.eclipse.etrice-636465baf602e2bc9ea0b6ae89c2bb255306eaaf.tar.xz
org.eclipse.etrice-636465baf602e2bc9ea0b6ae89c2bb255306eaaf.zip
Bug 546443 - [c.gen] Support special user code for library elements
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/build.gradle3
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/SubSystemUserCodeTest.room32
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/build.gradle b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
index 42d4d908d..5046158f5 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/build.gradle
+++ b/tests/org.eclipse.etrice.generator.common.tests/build.gradle
@@ -37,3 +37,6 @@ createTest('java', 'detailExpressionCompileTest', [genericPhysical, 'models/Deta
// VarargsTTest
createTest('c', 'varargsTest', [genericPhysical, 'models/VarargsTest.room'])
createTest('java', 'varargsTest', [genericPhysical, 'models/VarargsTest.room'])
+
+// SubSystemUserCodeTest
+createTest('c', 'subSystemUserCodeTest', ['models/SubSystemUserCodeTest.room', genericPhysical])
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/SubSystemUserCodeTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/SubSystemUserCodeTest.room
new file mode 100644
index 000000000..d93962daa
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/SubSystemUserCodeTest.room
@@ -0,0 +1,32 @@
+RoomModel SubSystemUserCodeTest {
+
+ import room.basic.annotations.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Annotations.room"
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Types.room"
+
+ ActorClass AGeneratedUserCode {
+ @TestInstance
+ @SubSystemUserCode(userCode="
+ int inSubSystemInstance(){ return 99; }
+ ")
+ Structure {
+ usercode3 '''
+ extern int inSubSystemInstance();
+ '''
+ }
+ Behavior {
+ ctor '''
+ etInt16 caseId = etUnit_openAll("log", "SubSystemUserCodeTest", "org.eclipse.etrice.generator.c.tests.SubSystemUserCodeTest", "SubSystemUserCodeTest_case");
+ EXPECT_EQUAL_INT32(caseId, "", 99, inSubSystemInstance());
+ etUnit_testFinished(caseId);
+ etUnit_closeAll(caseId);
+ '''
+
+ }
+ }
+
+ // no instance => no sub system user code
+ ActorClass ANotGenerated {
+ @SubSystemUserCode(userCode="int inSubSystemInstance(){ return 0; }")
+ }
+} \ No newline at end of file

Back to the top