correct metainformation export + test

This commit is contained in:
Alexey Fedoseev
2024-04-14 18:57:00 +03:00
parent 99bf4912cd
commit c02e24d16a
5 changed files with 300 additions and 67 deletions

View File

@@ -0,0 +1,46 @@
/* -----------------------------------------------------------------------------
* 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"
using namespace Cyberiada;
using namespace std;
#define CYB_ASSERT(q) if (!(q)) { \
throw AssertException(std::string(__FILE__) + ":" + std::to_string(__LINE__)); \
}
int main(int argc, char** argv)
{
Document d;
try {
d.load(string(argv[0]) + "-input.graphml", formatCyberiada10);
CYB_ASSERT(d.meta().name == "Test document");
d.set_name("Test document 2");
CYB_ASSERT(d.meta().name == "Test document 2");
cout << d << endl;
} catch (const Cyberiada::Exception& e) {
cerr << e.str() << endl;
return 1;
}
return 0;
}

View File

@@ -0,0 +1,62 @@
<?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
platform/ Berloga
platformVersion/ 1.4
platformLanguage/ script
target/ Unit
name/ Test document
author/ Author
contact/ platform@kruzhok.org
description/ 1
2
3
version/ 0.1
date/ 2024-04-14 11:22
markupLanguage/ html
transitionOrder/ exitFirst
eventPropagation/ propagate
</data>
</node>
</graph>
</graphml>

33
tests/05-output.txt Normal file
View File

@@ -0,0 +1,33 @@
Document [Cyberiada-GraphML-1.0] {Element type: doc, id: '', name: 'Test document 2', meta: {standard version: '1.0', platform name: 'Berloga', platform version: '1.4', platform language: 'script', target system: 'Unit', name: 'Test document 2', author: 'Author', contact: 'platform@kruzhok.org', description: '1
2
3', version: '0.1', date: '2024-04-14 11:22', markup language: 'html', transition order: exit first, event propagation: propagate events}, elements: {State Machine {Element type: stm, id: 'G0', name: 'SM', elements: {Comment { formal, Element type: fco, id: 'nMeta', name: 'CGML_META', body: 'standardVersion/ 1.0
platform/ Berloga
platformVersion/ 1.4
platformLanguage/ script
target/ Unit
name/ Test document 2
author/ Author
contact/ platform@kruzhok.org
description/ 1
2
3
version/ 0.1
date/ 2024-04-14 11:22
markupLanguage/ html
transitionOrder/ exitFirst
eventPropagation/ propagate
'}}}}