From d4d78727133d64cc9a927dd5d3ecf48030e4bfe9 Mon Sep 17 00:00:00 2001 From: Alexey Fedoseev Date: Thu, 25 Apr 2024 10:06:47 +0300 Subject: [PATCH] comment test --- tests/14-comments.cpp | 55 +++++++++++++++++++++++++++++++ tests/14-output.graphml | 71 +++++++++++++++++++++++++++++++++++++++++ tests/14-output.txt | 2 ++ 3 files changed, 128 insertions(+) create mode 100644 tests/14-comments.cpp create mode 100644 tests/14-output.graphml create mode 100644 tests/14-output.txt diff --git a/tests/14-comments.cpp b/tests/14-comments.cpp new file mode 100644 index 0000000..ec0f299 --- /dev/null +++ b/tests/14-comments.cpp @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------------- + * 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"); + Comment* comm = d.new_comment(sm, "Top level"); + try { + // check id uniqueness + d.new_comment(sm, "n0", "testname", "Testbody"); + } catch (const Cyberiada::ParametersException&){ + } + State* state = d.new_state(sm, "State", Action(actionEntry, "action();")); + Comment* comm2 = d.new_comment(state, "Comment inside a state\nwith two lines"); + d.new_formal_comment(sm, "Name", "Named formal comment"); + + d.add_comment_to_element(comm, state); + d.add_comment_to_element_name(comm2, state, "S"); + d.add_comment_to_element_body(comm2, state, "action"); + + try { + cout << d << endl; + d.save(string(argv[0]) + ".graphml", formatCyberiada10); + } catch (const Cyberiada::Exception&) { + return 1; + } + return 0; +} diff --git a/tests/14-output.graphml b/tests/14-output.graphml new file mode 100644 index 0000000..0e82ff3 --- /dev/null +++ b/tests/14-output.graphml @@ -0,0 +1,71 @@ + + + Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + SM + + formal + CGML_META + standardVersion/ 1.0 + +transitionOrder/ transitionFirst + +eventPropagation/ block + + + + + informal + Top level + + + State + entry/ +action(); + + + + informal + Comment inside a state +with two lines + + + + + formal + Name + Named formal comment + + + + + + dName + S + + + dData + action + + + diff --git a/tests/14-output.txt b/tests/14-output.txt new file mode 100644 index 0000000..c63320f --- /dev/null +++ b/tests/14-output.txt @@ -0,0 +1,2 @@ +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: {Comment: {id: 'n0', body: 'Top level', subjects: {{id: 'n0-n1', type: element, to: 'n1'}}}, Composite State: {id: 'n1', name: 'State', actions: {a {entry, behavior: 'action();'}}, elements: {Comment: {id: 'n1::n0', body: 'Comment inside a state +with two lines', subjects: {{id: 'n1::n0-n1', type: name, to: 'n1', fragment: 'S'}, {id: 'n1::n0-n1', type: data, to: 'n1', fragment: 'action'}}}}}, Formal Comment: {id: 'n2', name: 'Name', body: 'Named formal comment'}}}}