diff --git a/tests/16-autoborder.cpp b/tests/16-autoborder.cpp new file mode 100644 index 0000000..eb91f54 --- /dev/null +++ b/tests/16-autoborder.cpp @@ -0,0 +1,40 @@ +/* ----------------------------------------------------------------------------- + * 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" + +using namespace Cyberiada; +using namespace std; + +int main(int argc, char** argv) +{ + Document d; + try { + d.load(string(argv[0]) + "-input.graphml", formatCyberiada10); + cout << d << endl; + d.save(string(argv[0]) + ".graphml", formatCyberiada10); + } catch (const Cyberiada::Exception& e) { + cerr << e.str() << endl; + return 1; + } + return 0; +} diff --git a/tests/16-autoborder.test-input.graphml b/tests/16-autoborder.test-input.graphml new file mode 100644 index 0000000..40fcb61 --- /dev/null +++ b/tests/16-autoborder.test-input.graphml @@ -0,0 +1,125 @@ + + + +Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + formal + CGML_META + standardVersion/ 1.0 + +platform/ BearsTowerDefence + +name/ Автобортник + +author/ Матросов В.М. + +contact/ matrosov@mail.ru + +description/ Пример описания схемы, +который может быть многострочным, потому что так удобнее + +target/ Autoborder + + + + Бой + entry/ + +exit/ + + + + + + Сближение + entry/ +МодульДвижения.ДвигатьсяКЦели() + +exit/ + + + + + + Атака + entry/ +ОружиеЦелевое.АтаковатьЦель() + +exit/ + + + + + + + + Скан + entry/ +Сенсор.ПоискВрагаПоДистанции(мин) + +exit/ +Сенсор.ОстановкаПоиска() + + + + + + initial + + + + + + + + АнализаторЦели.ЦельУничтожена/ + + + + АнализаторЦели.ЦельПотеряна/ + + + + Сенсор.ЦельПолучена/ + + + + ОружиеЦелевое.ЦельВошлаВЗонуАтаки/ + + + + ОружиеЦелевое.ЦельВышлаИзЗоныАтаки/ + + + + + diff --git a/tests/16-output.graphml b/tests/16-output.graphml new file mode 100644 index 0000000..68f3c4a --- /dev/null +++ b/tests/16-output.graphml @@ -0,0 +1,117 @@ + + + Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + + + formal + CGML_META + standardVersion/ 1.0 + +platform/ BearsTowerDefence + +target/ Autoborder + +name/ Автобортник + +author/ Матросов В.М. + +contact/ matrosov@mail.ru + +description/ Пример описания схемы, +который может быть многострочным, потому что так удобнее + +transitionOrder/ transitionFirst + +eventPropagation/ block + + + + + Бой + entry/ + +exit/ + + + + + + Сближение + entry/ +МодульДвижения.ДвигатьсяКЦели() + +exit/ + + + + + + Атака + entry/ +ОружиеЦелевое.АтаковатьЦель() + +exit/ + + + + + + + + Скан + entry/ +Сенсор.ПоискВрагаПоДистанции(мин) + +exit/ +Сенсор.ОстановкаПоиска() + + + + + + + initial + + + + + + + + АнализаторЦели.ЦельУничтожена/ + + + АнализаторЦели.ЦельПотеряна/ + + + Сенсор.ЦельПолучена/ + + + ОружиеЦелевое.ЦельВошлаВЗонуАтаки/ + + + ОружиеЦелевое.ЦельВышлаИзЗоныАтаки/ + + + diff --git a/tests/16-output.txt b/tests/16-output.txt new file mode 100644 index 0000000..53e4f8e --- /dev/null +++ b/tests/16-output.txt @@ -0,0 +1,15 @@ +Document: {id: '', name: 'Автобортник', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', platform name: 'BearsTowerDefence', target system: 'Autoborder', name: 'Автобортник', author: 'Матросов В.М.', contact: 'matrosov@mail.ru', description: 'Пример описания схемы, +который может быть многострочным, потому что так удобнее', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: '', elements: {Formal Comment: {id: 'nMeta', name: 'CGML_META', body: 'standardVersion/ 1.0 + +platform/ BearsTowerDefence + +name/ Автобортник + +author/ Матросов В.М. + +contact/ matrosov@mail.ru + +description/ Пример описания схемы, +который может быть многострочным, потому что так удобнее + +target/ Autoborder'}, Composite State: {id: 'n0', name: 'Бой', actions: {a {entry}, a {exit}}, geometry: (-578.005; 438.187; 672.532; 802.963), elements: {Simple State: {id: 'n0::n1', name: 'Сближение', actions: {a {entry, behavior: 'МодульДвижения.ДвигатьсяКЦели()'}, a {exit}}, geometry: (-525.739; 609.669; 468; 170)}, Simple State: {id: 'n0::n2', name: 'Атака', actions: {a {entry, behavior: 'ОружиеЦелевое.АтаковатьЦель()'}, a {exit}}, geometry: (-630.271; 206.706; 468; 170)}}}, Simple State: {id: 'n3', name: 'Скан', actions: {a {entry, behavior: 'Сенсор.ПоискВрагаПоДистанции(мин)'}, a {exit, behavior: 'Сенсор.ОстановкаПоиска()'}}, geometry: (-1582.04; 606.498; 468; 330)}, Initial: {id: 'init', geometry: (-1482.04; 606.498)}, Transition: {id: 'init-n3', source: 'init', target: 'n3'}, Transition: {id: 'n0-n3', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельУничтожена'}}, Transition: {id: 'n0-n3', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельПотеряна'}}, Transition: {id: 'n3-n0::n1', source: 'n3', target: 'n0::n1', action: {trigger: 'Сенсор.ЦельПолучена'}}, Transition: {id: 'n0::n1-n0::n2', source: 'n0::n1', target: 'n0::n2', action: {trigger: 'ОружиеЦелевое.ЦельВошлаВЗонуАтаки'}}, Transition: {id: 'n0::n2-n0::n1', source: 'n0::n2', target: 'n0::n1', action: {trigger: 'ОружиеЦелевое.ЦельВышлаИзЗоныАтаки'}}}}}