initial & final vertexes in the doc interface + tests
This commit is contained in:
@@ -29,6 +29,11 @@ int main(int argc, char** argv)
|
||||
{
|
||||
Document d;
|
||||
d.new_state_machine("SM1");
|
||||
try {
|
||||
// check id uniqueness
|
||||
d.new_state_machine("G0", "SM2");
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
d.new_state_machine("SM2");
|
||||
try {
|
||||
cout << d << endl;
|
||||
|
||||
@@ -33,7 +33,17 @@ int main(int argc, char** argv)
|
||||
StateMachine* sm = d.new_state_machine("SM");
|
||||
|
||||
State* parent1 = d.new_state(sm, "Parent 0");
|
||||
d.new_state(parent1, "State 0-0");
|
||||
|
||||
try {
|
||||
// check id uniqueness
|
||||
d.new_state(sm, "n0", "test");
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
|
||||
CYB_ASSERT(parent1->is_simple_state());
|
||||
d.new_state(parent1, "State 0-0");
|
||||
CYB_ASSERT(parent1->is_composite_state());
|
||||
|
||||
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");
|
||||
@@ -41,6 +51,12 @@ int main(int argc, char** argv)
|
||||
State* parent2 = d.new_state(sm, "Parent 1");
|
||||
d.new_state(parent2, "State 1-0");
|
||||
d.new_state(parent2, "State 1-1");
|
||||
try {
|
||||
// check id uniqueness on the deep level
|
||||
d.new_state(parent2, "n1::n1", "test");
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
|
||||
try {
|
||||
cout << d << endl;
|
||||
d.save(string(argv[0]) + ".graphml", formatCyberiada10);
|
||||
|
||||
57
tests/09-initial.cpp
Normal file
57
tests/09-initial.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* The Cyberiada GraphML C++ library implemention
|
||||
*
|
||||
* The test
|
||||
*
|
||||
* Copyright (C) 2024 Alexey Fedoseev <aleksey@fedoseev.net>
|
||||
*
|
||||
* 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 <iostream>
|
||||
#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");
|
||||
|
||||
d.new_initial(sm);
|
||||
try {
|
||||
// check id uniqueness
|
||||
d.new_initial(sm, "n0");
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
|
||||
State* parent = d.new_state(sm, "State");
|
||||
d.new_initial(parent, "Local init");
|
||||
try {
|
||||
// check double initial
|
||||
d.new_initial(parent);
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
|
||||
try {
|
||||
cout << d << endl;
|
||||
d.save(string(argv[0]) + ".graphml", formatCyberiada10);
|
||||
} catch (const Cyberiada::Exception&) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
50
tests/09-initial.test-output.graphml
Normal file
50
tests/09-initial.test-output.graphml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
|
||||
<data key="gFormat">Cyberiada-GraphML-1.0</data>
|
||||
<key id="gFormat" for="graphml" attr.name="format" attr.type="string"/>
|
||||
<key id="dName" for="graph" attr.name="name" attr.type="string"/>
|
||||
<key id="dName" for="node" attr.name="name" attr.type="string"/>
|
||||
<key id="dStateMachine" for="graph" attr.name="stateMachine" attr.type="string"/>
|
||||
<key id="dSubmachineState" for="node" attr.name="submachineState" attr.type="string"/>
|
||||
<key id="dGeometry" for="graph" attr.name="geometry"/>
|
||||
<key id="dGeometry" for="node" attr.name="geometry"/>
|
||||
<key id="dGeometry" for="edge" attr.name="geometry"/>
|
||||
<key id="dSourcePoint" for="edge" attr.name="sourcePoint"/>
|
||||
<key id="dTargetPoint" for="edge" attr.name="targetPoint"/>
|
||||
<key id="dLabelGeometry" for="edge" attr.name="labelGeometry"/>
|
||||
<key id="dNote" for="node" attr.name="note" attr.type="string"/>
|
||||
<key id="dVertex" for="node" attr.name="vertex" attr.type="string"/>
|
||||
<key id="dData" for="node" attr.name="data" attr.type="string"/>
|
||||
<key id="dData" for="edge" attr.name="data" attr.type="string"/>
|
||||
<key id="dMarkup" for="node" attr.name="markup" attr.type="string"/>
|
||||
<key id="dColor" for="node" attr.name="color" attr.type="string"/>
|
||||
<key id="dColor" for="edge" attr.name="color" attr.type="string"/>
|
||||
<key id="dPivot" for="edge" attr.name="pivot" attr.type="string"/>
|
||||
<key id="dChunk" for="edge" attr.name="chunk" attr.type="string"/>
|
||||
<graph id="G0" edgedefault="directed">
|
||||
<data key="dName">SM</data>
|
||||
<node id="nMeta">
|
||||
<data key="dNote">formal</data>
|
||||
<data key="dName">CGML_META</data>
|
||||
<data key="dData">standardVersion/ 1.0
|
||||
|
||||
transitionOrder/ transitionFirst
|
||||
|
||||
eventPropagation/ block
|
||||
|
||||
</data>
|
||||
</node>
|
||||
<node id="n0">
|
||||
<data key="dVertex">initial</data>
|
||||
</node>
|
||||
<node id="n1">
|
||||
<data key="dName">State</data>
|
||||
<graph id="n1:" edgedefault="directed">
|
||||
<node id="n1::n0">
|
||||
<data key="dVertex">initial</data>
|
||||
<data key="dName">Local init</data>
|
||||
</node>
|
||||
</graph>
|
||||
</node>
|
||||
</graph>
|
||||
</graphml>
|
||||
1
tests/09-output.txt
Normal file
1
tests/09-output.txt
Normal file
@@ -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: {Initial: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Initial: {id: 'n1::n0', name: 'Local init'}}}}}}
|
||||
52
tests/10-final.cpp
Normal file
52
tests/10-final.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* The Cyberiada GraphML C++ library implemention
|
||||
*
|
||||
* The test
|
||||
*
|
||||
* Copyright (C) 2024 Alexey Fedoseev <aleksey@fedoseev.net>
|
||||
*
|
||||
* 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 <iostream>
|
||||
#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");
|
||||
|
||||
d.new_final(sm);
|
||||
try {
|
||||
// check id uniqueness
|
||||
d.new_final(sm, "n0", "test");
|
||||
} catch (const Cyberiada::ParametersException&){
|
||||
}
|
||||
|
||||
State* parent = d.new_state(sm, "State");
|
||||
d.new_final(parent, "Local exit");
|
||||
|
||||
try {
|
||||
cout << d << endl;
|
||||
d.save(string(argv[0]) + ".graphml", formatCyberiada10);
|
||||
} catch (const Cyberiada::Exception&) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
50
tests/10-final.test-output.graphml
Normal file
50
tests/10-final.test-output.graphml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
|
||||
<data key="gFormat">Cyberiada-GraphML-1.0</data>
|
||||
<key id="gFormat" for="graphml" attr.name="format" attr.type="string"/>
|
||||
<key id="dName" for="graph" attr.name="name" attr.type="string"/>
|
||||
<key id="dName" for="node" attr.name="name" attr.type="string"/>
|
||||
<key id="dStateMachine" for="graph" attr.name="stateMachine" attr.type="string"/>
|
||||
<key id="dSubmachineState" for="node" attr.name="submachineState" attr.type="string"/>
|
||||
<key id="dGeometry" for="graph" attr.name="geometry"/>
|
||||
<key id="dGeometry" for="node" attr.name="geometry"/>
|
||||
<key id="dGeometry" for="edge" attr.name="geometry"/>
|
||||
<key id="dSourcePoint" for="edge" attr.name="sourcePoint"/>
|
||||
<key id="dTargetPoint" for="edge" attr.name="targetPoint"/>
|
||||
<key id="dLabelGeometry" for="edge" attr.name="labelGeometry"/>
|
||||
<key id="dNote" for="node" attr.name="note" attr.type="string"/>
|
||||
<key id="dVertex" for="node" attr.name="vertex" attr.type="string"/>
|
||||
<key id="dData" for="node" attr.name="data" attr.type="string"/>
|
||||
<key id="dData" for="edge" attr.name="data" attr.type="string"/>
|
||||
<key id="dMarkup" for="node" attr.name="markup" attr.type="string"/>
|
||||
<key id="dColor" for="node" attr.name="color" attr.type="string"/>
|
||||
<key id="dColor" for="edge" attr.name="color" attr.type="string"/>
|
||||
<key id="dPivot" for="edge" attr.name="pivot" attr.type="string"/>
|
||||
<key id="dChunk" for="edge" attr.name="chunk" attr.type="string"/>
|
||||
<graph id="G0" edgedefault="directed">
|
||||
<data key="dName">SM</data>
|
||||
<node id="nMeta">
|
||||
<data key="dNote">formal</data>
|
||||
<data key="dName">CGML_META</data>
|
||||
<data key="dData">standardVersion/ 1.0
|
||||
|
||||
transitionOrder/ transitionFirst
|
||||
|
||||
eventPropagation/ block
|
||||
|
||||
</data>
|
||||
</node>
|
||||
<node id="n0">
|
||||
<data key="dVertex">final</data>
|
||||
</node>
|
||||
<node id="n1">
|
||||
<data key="dName">State</data>
|
||||
<graph id="n1:" edgedefault="directed">
|
||||
<node id="n1::n0">
|
||||
<data key="dVertex">final</data>
|
||||
<data key="dName">Local exit</data>
|
||||
</node>
|
||||
</graph>
|
||||
</node>
|
||||
</graph>
|
||||
</graphml>
|
||||
1
tests/10-output.txt
Normal file
1
tests/10-output.txt
Normal file
@@ -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: {Final: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Final: {id: 'n1::n0', name: 'Local exit'}}}}}}
|
||||
Reference in New Issue
Block a user