From a2c1e41e5cc39c6d1f7056c59fe416af6e798778 Mon Sep 17 00:00:00 2001 From: Alexey Fedoseev Date: Mon, 22 Apr 2024 22:08:02 +0300 Subject: [PATCH] state hierarchy test --- tests/08-output.txt | 1 + tests/08-state-hierarchy.cpp | 51 +++++++++++++++ tests/08-state-hierarchy.test-output.graphml | 68 ++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 tests/08-output.txt create mode 100644 tests/08-state-hierarchy.cpp create mode 100644 tests/08-state-hierarchy.test-output.graphml diff --git a/tests/08-output.txt b/tests/08-output.txt new file mode 100644 index 0000000..9c20975 --- /dev/null +++ b/tests/08-output.txt @@ -0,0 +1 @@ +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Composite State: {id: 'n0', name: 'Parent 0', elements: {Simple State: {id: 'n0::n0', name: 'State 0-0'}, Composite State: {id: 'n0::n1', name: 'Subparent 0-1', elements: {Simple State: {id: 'n0::n1::n0', name: 'State 0-1-0'}, Simple State: {id: 'n0::n1::n1', name: 'State 0-1-1'}}}}}, Composite State: {id: 'n1', name: 'Parent 1', elements: {Simple State: {id: 'n1::n0', name: 'State 1-0'}, Simple State: {id: 'n1::n1', name: 'State 1-1'}}}}}} diff --git a/tests/08-state-hierarchy.cpp b/tests/08-state-hierarchy.cpp new file mode 100644 index 0000000..9b70185 --- /dev/null +++ b/tests/08-state-hierarchy.cpp @@ -0,0 +1,51 @@ +/* ----------------------------------------------------------------------------- + * The Cyberiada GraphML C++ library implemention + * + * The test + * + * Copyright (C) 2024 Alexey Fedoseev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/ + * ----------------------------------------------------------------------------- */ + +#include +#include "cyberiadamlpp.h" +#include "testutils.h" + +using namespace Cyberiada; +using namespace std; + +int main(int argc, char** argv) +{ + Document d; + + StateMachine* sm = d.new_state_machine("SM"); + + State* parent1 = d.new_state(sm, "Parent 0"); + d.new_state(parent1, "State 0-0"); + State* subparent = d.new_state(parent1, "Subparent 0-1"); + d.new_state(subparent, "State 0-1-0"); + d.new_state(subparent, "State 0-1-1"); + + State* parent2 = d.new_state(sm, "Parent 1"); + d.new_state(parent2, "State 1-0"); + d.new_state(parent2, "State 1-1"); + try { + cout << d << endl; + d.save(string(argv[0]) + ".graphml", formatCyberiada10); + } catch (const Cyberiada::Exception&) { + return 1; + } + return 0; +} diff --git a/tests/08-state-hierarchy.test-output.graphml b/tests/08-state-hierarchy.test-output.graphml new file mode 100644 index 0000000..1d6fe40 --- /dev/null +++ b/tests/08-state-hierarchy.test-output.graphml @@ -0,0 +1,68 @@ + + + Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + SM + + formal + CGML_META + standardVersion/ 1.0 + +transitionOrder/ transitionFirst + +eventPropagation/ block + + + + + Parent 0 + + + State 0-0 + + + Subparent 0-1 + + + State 0-1-0 + + + State 0-1-1 + + + + + + + Parent 1 + + + State 1-0 + + + State 1-1 + + + + +