From 9d8a7818da0a7c56ce844d9d1eeb1ce2867594d8 Mon Sep 17 00:00:00 2001 From: Axel Terfloth Date: Mon, 8 Feb 2016 22:55:36 +0100 Subject: [PATCH] added c generator tests for issue #355 --- .../gtests/ReadOnlyVariable/ xxx | 1 - .../TriggerExpressionPrecedence.cc | 51 +++++++++++++++++++ .../TriggerExpressionPrecedence.sgen | 19 +++++++ .../model/test.sgen | 24 +++++++++ .../sct/generator/c/test/AllTests.java | 3 +- .../c/test/TriggerExpressionPrecedence.java | 39 ++++++++++++++ 6 files changed, 135 insertions(+), 2 deletions(-) delete mode 100644 test-plugins/org.yakindu.sct.generator.c.test/gtests/ReadOnlyVariable/ xxx create mode 100644 test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc create mode 100644 test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.sgen create mode 100644 test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/TriggerExpressionPrecedence.java diff --git a/test-plugins/org.yakindu.sct.generator.c.test/gtests/ReadOnlyVariable/ xxx b/test-plugins/org.yakindu.sct.generator.c.test/gtests/ReadOnlyVariable/ xxx deleted file mode 100644 index d6459e0054..0000000000 --- a/test-plugins/org.yakindu.sct.generator.c.test/gtests/ReadOnlyVariable/ xxx +++ /dev/null @@ -1 +0,0 @@ -xxx diff --git a/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc b/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc new file mode 100644 index 0000000000..4845b67f82 --- /dev/null +++ b/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc @@ -0,0 +1,51 @@ +/** +* 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 +#include "gtest/gtest.h" +#include "TriggerExpressionPrecedence.h" + + +TriggerExpressionPrecedence handle; + +TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrFalse) { + triggerExpressionPrecedence_init(&handle); + triggerExpressionPrecedence_enter(&handle); + triggerExpressionPrecedenceIface_set_c1(&handle, false); + triggerExpressionPrecedenceIface_set_c2(&handle, false); + triggerExpressionPrecedence_runCycle(&handle); + EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) ); +} +TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrFalse) { + triggerExpressionPrecedence_init(&handle); + triggerExpressionPrecedence_enter(&handle); + triggerExpressionPrecedenceIface_set_c1(&handle, true); + triggerExpressionPrecedenceIface_set_c2(&handle, false); + triggerExpressionPrecedence_runCycle(&handle); + EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) ); +} +TEST(StatemachineTest, unsatisfiedTriggerAndFGuardFalseOrTrue) { + triggerExpressionPrecedence_init(&handle); + triggerExpressionPrecedence_enter(&handle); + triggerExpressionPrecedenceIface_set_c1(&handle, false); + triggerExpressionPrecedenceIface_set_c2(&handle, true); + triggerExpressionPrecedence_runCycle(&handle); + EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) ); +} +TEST(StatemachineTest, unsatisfiedTriggerAndFGuardTrueOrTrue) { + triggerExpressionPrecedence_init(&handle); + triggerExpressionPrecedence_enter(&handle); + triggerExpressionPrecedenceIface_set_c1(&handle, true); + triggerExpressionPrecedenceIface_set_c2(&handle, true); + triggerExpressionPrecedence_runCycle(&handle); + EXPECT_TRUE(!triggerExpressionPrecedenceIface_get_e1_transition(&handle) ); +} + + diff --git a/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.sgen b/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.sgen new file mode 100644 index 0000000000..1c4e1f4e69 --- /dev/null +++ b/test-plugins/org.yakindu.sct.generator.c.test/gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence.sgen @@ -0,0 +1,19 @@ +GeneratorModel for yakindu::c { + statechart TriggerExpressionPrecedence { + feature Outlet { + targetProject = "gtests" + targetFolder = "TriggerExpressionPrecedence" + } + feature FunctionInlining { + inlineReactions = false + inlineEntryActions = false + inlineEnterSequences = false + inlineExitActions = false + inlineExitSequences = false + inlineChoices = false + inlineEntries = false + inlineEnterRegion = false + inlineExitRegion = false + } + } +} diff --git a/test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen b/test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen index 1f57c34bde..f4b61daac0 100644 --- a/test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen +++ b/test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen @@ -1355,6 +1355,30 @@ GeneratorModel for sctunit::c { } } + test TriggerExpressionPrecedence { + + feature Outlet{ + targetProject = "org.yakindu.sct.generator.c.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 TriggerGuardExpressions{ feature Outlet{ diff --git a/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java b/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java index 17d11ca334..07e9d7d170 100644 --- a/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java +++ b/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/AllTests.java @@ -26,6 +26,7 @@ SameNameDifferentRegion.class, ShallowHistory.class, ShallowHistoryWithDeepEntry.class, SimpleEvent.class, SimpleHierachy.class, StatechartActive.class, StatechartLocalReactions.class, StateIsActive.class, StaticChoice.class, STextKeywordsInStatesAndRegions.class, StringExpressions.class, SyncFork.class, - SyncJoin.class, TransitionWithoutCondition.class, TriggerGuardExpressions.class, ValuedEvents.class}) + SyncJoin.class, TransitionWithoutCondition.class, TriggerGuardExpressions.class, + TriggerExpressionPrecedence.class, ValuedEvents.class}) public class AllTests { } diff --git a/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/TriggerExpressionPrecedence.java b/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/TriggerExpressionPrecedence.java new file mode 100644 index 0000000000..8b760ef648 --- /dev/null +++ b/test-plugins/org.yakindu.sct.generator.c.test/test-gen/org/yakindu/sct/generator/c/test/TriggerExpressionPrecedence.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/TriggerExpressionPrecedence/TriggerExpressionPrecedence.cc", program = "gtests/TriggerExpressionPrecedence/TriggerExpressionPrecedence", model = "testmodels/SCTUnit/expressions/TriggerExpressionPrecedence.sct") +@RunWith(GTestRunner.class) +public class TriggerExpressionPrecedence { + + protected final GTestHelper helper = new GTestHelper(this) { + + @Override + protected void getSourceFiles(Collection files) { + super.getSourceFiles(files); + files.add(getFileName(getTestProgram()) + ".c"); + } + }; + + @Before + public void setUp() { + helper.generate(); + helper.compile(); + } +}