From 02b6a62268c0ed4b8ce7d02f129985a3fa9c3908 Mon Sep 17 00:00:00 2001 From: Alexey Fedoseev Date: Sat, 27 Apr 2024 11:52:42 +0300 Subject: [PATCH] add YED geometry import tests --- tests/17-output.graphml | 28 +-- tests/17-output.txt | 2 +- tests/18-output.graphml | 86 ++++---- tests/18-output.txt | 6 +- tests/19-legacy-geometry.cpp | 40 ++++ tests/19-legacy-geometry.test-input.graphml | 208 +++++++++++++++++++ tests/19-output.graphml | 114 ++++++++++ tests/19-output.txt | 1 + tests/20-legacy-geometry2.cpp | 40 ++++ tests/20-legacy-geometry2.test-input.graphml | 192 +++++++++++++++++ tests/20-output.graphml | 111 ++++++++++ tests/20-output.txt | 1 + 12 files changed, 768 insertions(+), 61 deletions(-) create mode 100644 tests/19-legacy-geometry.cpp create mode 100644 tests/19-legacy-geometry.test-input.graphml create mode 100644 tests/19-output.graphml create mode 100644 tests/19-output.txt create mode 100644 tests/20-legacy-geometry2.cpp create mode 100644 tests/20-legacy-geometry2.test-input.graphml create mode 100644 tests/20-output.graphml create mode 100644 tests/20-output.txt diff --git a/tests/17-output.graphml b/tests/17-output.graphml index 086441f..af76146 100644 --- a/tests/17-output.graphml +++ b/tests/17-output.graphml @@ -59,7 +59,7 @@ exit/ exit/ - + @@ -69,7 +69,7 @@ exit/ exit/ - + @@ -89,54 +89,54 @@ exit/ АнализаторЦели.ЦельПотеряна/ - + - + АнализаторЦели.ЦельУничтожена/ - + - + Сенсор.ЦельПолучена/ - + - + ОружиеЦелевое.ЦельВошлаВЗонуАтаки/ - + - + ОружиеЦелевое.ЦельВышлаИзЗоныАтаки/ - + - + - + - + diff --git a/tests/17-output.txt b/tests/17-output.txt index 32e3a81..da9c27a 100644 --- a/tests/17-output.txt +++ b/tests/17-output.txt @@ -1 +1 @@ -Document: {id: '', name: 'Автобортник', format: 'yEd Berloga', meta: {standard version: '1.0', name: 'Автобортник', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'Автобортник', elements: {Initial: {id: 'n1', name: '', geometry: (-1623; 753)}, Composite State: {id: 'n0', name: 'Бой', actions: {a {entry}, a {exit}}, geometry: (-786; 492; 517; 770), elements: {Simple State: {id: 'n0::n1', name: 'Сближение', actions: {a {entry, behavior: 'МодульДвижения.ДвигатьсяКЦели()'}, a {exit}}, geometry: (-788; 645; 413; 208)}, Simple State: {id: 'n0::n2', name: 'Атака', actions: {a {entry, behavior: 'ОружиеЦелевое.АтаковатьЦель()'}, a {exit}}, geometry: (-784; 311; 413; 208)}}}, Simple State: {id: 'n3', name: 'Скан', actions: {a {entry, behavior: 'Сенсор.ПоискВрагаПоДистанции(мин)'}, a {exit, behavior: 'Сенсор.ОстановкаПоиска()'}}, geometry: (-1573; 738; 413; 288)}, Transition: {id: 'n0-n3', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельПотеряна'}, sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0-n3#0', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельУничтожена'}, sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n3-n0::n1', source: 'n3', target: 'n0::n1', action: {trigger: 'Сенсор.ЦельПолучена'}, sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0::n1-n0::n2', source: 'n0::n1', target: 'n0::n2', action: {trigger: 'ОружиеЦелевое.ЦельВошлаВЗонуАтаки'}, sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0::n2-n0::n1', source: 'n0::n2', target: 'n0::n1', action: {trigger: 'ОружиеЦелевое.ЦельВышлаИзЗоныАтаки'}, sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n1-n3', source: 'n1', target: 'n3', sp: (0; 0), tp: (0; 0)}}}} +Document: {id: '', name: 'Автобортник', format: 'yEd Berloga', meta: {standard version: '1.0', name: 'Автобортник', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'Автобортник', elements: {Initial: {id: 'n1', name: '', geometry: (-1623; 753)}, Composite State: {id: 'n0', name: 'Бой', actions: {a {entry}, a {exit}}, geometry: (-786; 492; 517; 770), elements: {Simple State: {id: 'n0::n1', name: 'Сближение', actions: {a {entry, behavior: 'МодульДвижения.ДвигатьсяКЦели()'}, a {exit}}, geometry: (-2; 153; 413; 208)}, Simple State: {id: 'n0::n2', name: 'Атака', actions: {a {entry, behavior: 'ОружиеЦелевое.АтаковатьЦель()'}, a {exit}}, geometry: (2; -181; 413; 208)}}}, Simple State: {id: 'n3', name: 'Скан', actions: {a {entry, behavior: 'Сенсор.ПоискВрагаПоДистанции(мин)'}, a {exit, behavior: 'Сенсор.ОстановкаПоиска()'}}, geometry: (-1573; 738; 413; 288)}, Transition: {id: 'n0-n3', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельПотеряна'}, sp: (0; 383.459), tp: (413; 142.769)}, Transition: {id: 'n0-n3#0', source: 'n0', target: 'n3', action: {trigger: 'АнализаторЦели.ЦельУничтожена'}, sp: (0; 383.459), tp: (413; 142.769)}, Transition: {id: 'n3-n0::n1', source: 'n3', target: 'n0::n1', action: {trigger: 'Сенсор.ЦельПолучена'}, sp: (413; 109.013), tp: (0; 69.0134)}, Transition: {id: 'n0::n1-n0::n2', source: 'n0::n1', target: 'n0::n2', action: {trigger: 'ОружиеЦелевое.ЦельВошлаВЗонуАтаки'}, sp: (413; 0), tp: (0; 208)}, Transition: {id: 'n0::n2-n0::n1', source: 'n0::n2', target: 'n0::n1', action: {trigger: 'ОружиеЦелевое.ЦельВышлаИзЗоныАтаки'}, sp: (0; 208), tp: (413; 0)}, Transition: {id: 'n1-n3', source: 'n1', target: 'n3', sp: (8.9338; 4.49302), tp: (0; 247.854)}}}} diff --git a/tests/18-output.graphml b/tests/18-output.graphml index f839792..6cf9f1c 100644 --- a/tests/18-output.graphml +++ b/tests/18-output.graphml @@ -52,7 +52,7 @@ exit/ orientation.stop_motor(AXIS_Z) - + @@ -61,7 +61,7 @@ orientation.stop_motor(AXIS_Z) reduce_speed() - + @@ -70,14 +70,14 @@ reduce_speed() calculate_turn() - + initial - + @@ -86,7 +86,7 @@ calculate_turn() complete_turn() - + @@ -95,14 +95,14 @@ complete_turn() idle entry/ - + wait entry/ - + @@ -114,7 +114,7 @@ exit/ orientation.stop_motor(AXIS_Z) - + @@ -123,7 +123,7 @@ orientation.stop_motor(AXIS_Z) orientation.set_motor_moment(AXIS_Z, -M) - + @@ -132,14 +132,14 @@ orientation.set_motor_moment(AXIS_Z, -M) orientation.set_motor_moment(AXIS_Z, M) - + initial - + @@ -148,14 +148,14 @@ orientation.set_motor_moment(AXIS_Z, M) static entry/ - + initial - + @@ -181,10 +181,10 @@ test3sm_orient.py - + - + @@ -194,10 +194,10 @@ test3sm_orient.py - + - + @@ -211,10 +211,10 @@ update_turn_parameters(target_a, 0.0) - + - + @@ -228,10 +228,10 @@ update_turn_parameters(target_a, 180.0) - + - + @@ -239,19 +239,19 @@ update_turn_parameters(target_a, 180.0) - + - + [completed()]/ - + - + @@ -260,10 +260,10 @@ update_turn_parameters(target_a, 180.0) [completed()]/ - + - + @@ -278,10 +278,10 @@ DISPATCH(navigation, 'ORIENTED') - + - + @@ -290,10 +290,10 @@ DISPATCH(navigation, 'ORIENTED') [orientation.get_angular_velocity(AXIS_Z) < DW]/ - + - + @@ -302,10 +302,10 @@ DISPATCH(navigation, 'ORIENTED') [orientation.get_angular_velocity(AXIS_Z) > DW]/ - + - + @@ -313,18 +313,18 @@ DISPATCH(navigation, 'ORIENTED') - + - + - + - + @@ -333,10 +333,10 @@ DISPATCH(navigation, 'ORIENTED') - + - + @@ -345,10 +345,10 @@ DISPATCH(navigation, 'ORIENTED') [is_target_dw()]/ - + - + @@ -357,10 +357,10 @@ DISPATCH(navigation, 'ORIENTED') [not is_target_dw()]/ - + - + diff --git a/tests/18-output.txt b/tests/18-output.txt index a9988a3..0dadd62 100644 --- a/tests/18-output.txt +++ b/tests/18-output.txt @@ -1,5 +1,5 @@ -Document: {id: '', name: 'orientation', format: 'yEd Ostranna', meta: {standard version: '1.0', name: 'orientation', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'orientation', elements: {Composite State: {id: 'n0', name: 'orientation', actions: {a {entry}}, geometry: (409.905; 50.5953; 1149.48; 725.384), elements: {Composite State: {id: 'n0::n0', name: 'turn', actions: {a {entry, behavior: 'orientation.start_motor(AXIS_Z)'}, a {exit, behavior: 'orientation.stop_motor(AXIS_Z)'}}, geometry: (445.462; 97.7135; 297.495; 506.213), elements: {Simple State: {id: 'n0::n0::n0', name: 'slow_down', actions: {a {entry, behavior: 'reduce_speed()'}}, geometry: (460.462; 286.453; 267.495; 69.2119)}, Simple State: {id: 'n0::n0::n1', name: 'start_turn', actions: {a {entry, behavior: 'calculate_turn()'}}, geometry: (460.462; 396.384; 267.495; 69.2119)}, Initial: {id: 'n0::n0::n2', name: '', geometry: (594.209; 247.953)}, Simple State: {id: 'n0::n0::n3', name: 'finish_turn', actions: {a {entry, behavior: 'complete_turn()'}}, geometry: (460.462; 506.315; 267.495; 69.2119)}}}, Simple State: {id: 'n0::n1', name: 'idle', actions: {a {entry}}, geometry: (766.168; 103.962; 313.217; 117.952)}, Composite State: {id: 'n0::n2', name: 'wait', actions: {a {entry}}, geometry: (1102.6; 106.937; 432.213; 640.663), elements: {Composite State: {id: 'n0::n2::n0', name: 'maintain', actions: {a {entry, behavior: 'orientation.start_motor(AXIS_Z)'}, a {exit, behavior: 'orientation.stop_motor(AXIS_Z)'}}, geometry: (1121.6; 320.744; 393.6; 400.074), elements: {Simple State: {id: 'n0::n2::n0::n0', name: 'correct_cw', actions: {a {entry, behavior: 'orientation.set_motor_moment(AXIS_Z, -M)'}}, geometry: (1140.35; 479.237; 358.315; 75.3372)}, Simple State: {id: 'n0::n2::n0::n1', name: 'correct_ccw', actions: {a {entry, behavior: 'orientation.set_motor_moment(AXIS_Z, M)'}}, geometry: (1140.35; 624.163; 358.315; 75.3372)}, Initial: {id: 'n0::n2::n0::n2', name: '', geometry: (1319.51; 436.353)}}}, Simple State: {id: 'n0::n2::n1', name: 'static', actions: {a {entry}}, geometry: (1122.71; 201.439; 393.6; 75.3372)}, Initial: {id: 'n0::n2::n2', name: '', geometry: (1319.51; 158.554)}}}}}, Initial: {id: 'n1', name: '', geometry: (945.784; -25.4024)}, Comment: {id: 'n2', body: 'Init scripts: +Document: {id: '', name: 'orientation', format: 'yEd Ostranna', meta: {standard version: '1.0', name: 'orientation', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'orientation', elements: {Composite State: {id: 'n0', name: 'orientation', actions: {a {entry}}, geometry: (409.905; 50.5953; 1149.48; 725.384), elements: {Composite State: {id: 'n0::n0', name: 'turn', actions: {a {entry, behavior: 'orientation.start_motor(AXIS_Z)'}, a {exit, behavior: 'orientation.stop_motor(AXIS_Z)'}}, geometry: (35.5575; 47.1182; 297.495; 506.213), elements: {Simple State: {id: 'n0::n0::n0', name: 'slow_down', actions: {a {entry, behavior: 'reduce_speed()'}}, geometry: (15; 188.739; 267.495; 69.2119)}, Simple State: {id: 'n0::n0::n1', name: 'start_turn', actions: {a {entry, behavior: 'calculate_turn()'}}, geometry: (15; 298.671; 267.495; 69.2119)}, Initial: {id: 'n0::n0::n2', name: '', geometry: (148.747; 150.239)}, Simple State: {id: 'n0::n0::n3', name: 'finish_turn', actions: {a {entry, behavior: 'complete_turn()'}}, geometry: (15; 408.602; 267.495; 69.2119)}}}, Simple State: {id: 'n0::n1', name: 'idle', actions: {a {entry}}, geometry: (356.263; 53.3672; 313.217; 117.952)}, Composite State: {id: 'n0::n2', name: 'wait', actions: {a {entry}}, geometry: (692.692; 56.3415; 432.213; 640.663), elements: {Composite State: {id: 'n0::n2::n0', name: 'maintain', actions: {a {entry, behavior: 'orientation.start_motor(AXIS_Z)'}, a {exit, behavior: 'orientation.stop_motor(AXIS_Z)'}}, geometry: (19; 213.807; 393.6; 400.074), elements: {Simple State: {id: 'n0::n2::n0::n0', name: 'correct_cw', actions: {a {entry, behavior: 'orientation.set_motor_moment(AXIS_Z, -M)'}}, geometry: (18.7537; 158.493; 358.315; 75.3372)}, Simple State: {id: 'n0::n2::n0::n1', name: 'correct_ccw', actions: {a {entry, behavior: 'orientation.set_motor_moment(AXIS_Z, M)'}}, geometry: (18.7537; 303.419; 358.315; 75.3372)}, Initial: {id: 'n0::n2::n0::n2', name: '', geometry: (197.911; 115.609)}}}, Simple State: {id: 'n0::n2::n1', name: 'static', actions: {a {entry}}, geometry: (20.1112; 94.5019; 393.6; 75.3372)}, Initial: {id: 'n0::n2::n2', name: '', geometry: (216.911; 51.617)}}}}}, Initial: {id: 'n1', name: '', geometry: (945.784; -25.4024)}, Comment: {id: 'n2', body: 'Init scripts: test3sm_constants.py -test3sm_orient.py', geometry: (445.462; 652.554; 160.084; 95.0456)}, Transition: {id: 'e0', source: 'n1', target: 'n0::n1', sp: (0; 0), tp: (23.0079; -7.04775)}, Transition: {id: 'e1', source: 'n0', target: 'n0::n1', action: {trigger: 'STOP'}, sp: (-157.872; -122.809), tp: (-4.11896; -7.29727), label: (-50.9045; -43.7766), polyline: [ (826.77; -4.95139), (918.657; -4.95139) ]}, Transition: {id: 'n0::e0', source: 'n0::n1', target: 'n0::n0', action: {trigger: 'TANGENT(target_a)', behavior: 'update_turn_parameters(target_a, 0.0)'}, sp: (95.232; 21.0292), tp: (129.208; 23.5618), label: (-248.977; 112.881), polyline: [ (1018.01; 374.382) ]}, Transition: {id: 'n0::e1', source: 'n0::n1', target: 'n0::n0', action: {trigger: 'BACK(target_a)', behavior: 'update_turn_parameters(target_a, 180.0)'}, sp: (113.643; 25.9294), tp: (148.774; 117.967), label: (-263.427; 205.217), polyline: [ (1036.42; 468.787) ]}, Transition: {id: 'n0::n0::e0', source: 'n0::n0::n2', target: 'n0::n0::n0', sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0::n0::e1', source: 'n0::n0::n0', target: 'n0::n0::n1', action: {guard: 'completed()'}, sp: (0; 0), tp: (0; 0), label: (1.57495; 11.3862)}, Transition: {id: 'n0::n0::e2', source: 'n0::n0::n1', target: 'n0::n0::n3', action: {guard: 'completed()'}, sp: (0; 0), tp: (0; 0), label: (5.91246; 11.3862)}, Transition: {id: 'n0::e2', source: 'n0::n2', target: 'n0::n1', action: {trigger: 'TIME_TICK', guard: 'orientation_completed()', behavior: 'DISPATCH(cpu, 'ORIENTED') -DISPATCH(navigation, 'ORIENTED')'}, sp: (-216.094; 98.8431), tp: (128.22; 13.3933), label: (-237.116; 17.6562), polyline: [ (1051; 526.111) ]}, Transition: {id: 'n0::n2::n0::e0', source: 'n0::n2::n0::n0', target: 'n0::n2::n0::n1', action: {guard: 'orientation.get_angular_velocity(AXIS_Z) < DW'}, sp: (-154.389; 1.81038), tp: (-154.389; 5.48153), label: (11.4035; 9.5621)}, Transition: {id: 'n0::n2::n0::e1', source: 'n0::n2::n0::n1', target: 'n0::n2::n0::n0', action: {guard: 'orientation.get_angular_velocity(AXIS_Z) > DW'}, sp: (163.3; -10.0207), tp: (163.3; 1.09301), label: (-299.03; -26.1772)}, Transition: {id: 'n0::n2::n0::e2', source: 'n0::n2::n0::n2', target: 'n0::n2::n0::n0', sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0::n2::e0', source: 'n0::n2::n2', target: 'n0::n2::n1', sp: (0; 0), tp: (0; 0)}, Transition: {id: 'n0::e3', source: 'n0::n0::n3', target: 'n0::n2', action: {guard: 'completed()'}, sp: (71.4174; 14.495), tp: (-17.6166; 284.015), label: (17.5826; 96.7526), polyline: [ (665.627; 711.284) ]}, Transition: {id: 'n0::n2::e1', source: 'n0::n2::n0', target: 'n0::n2::n1', action: {guard: 'is_target_dw()'}, sp: (138.108; -80.2858), tp: (136.997; 11.0857), label: (-100.932; -30.9909)}, Transition: {id: 'n0::n2::e2', source: 'n0::n2::n1', target: 'n0::n2::n0', action: {guard: 'not is_target_dw()'}, sp: (-136.091; 13.4535), tp: (-134.98; -169.298), label: (9.66948; 13.8096)}}}} +test3sm_orient.py', geometry: (445.462; 652.554; 160.084; 95.0456)}, Transition: {id: 'e0', source: 'n1', target: 'n0::n1', sp: (0; 10), tp: (156.608; 0)}, Transition: {id: 'e1', source: 'n0', target: 'n0::n1', action: {trigger: 'STOP'}, sp: (574.738; 0), tp: (156.608; 0), label: (-50.9045; -43.7766), polyline: [ (826.77; -4.95139), (918.657; -4.95139) ]}, Transition: {id: 'n0::e0', source: 'n0::n1', target: 'n0::n0', action: {trigger: 'TANGENT(target_a)', behavior: 'update_turn_parameters(target_a, 0.0)'}, sp: (156.608; 117.952), tp: (297.495; 276.668), label: (-248.977; 112.881), polyline: [ (1018.01; 374.382) ]}, Transition: {id: 'n0::e1', source: 'n0::n1', target: 'n0::n0', action: {trigger: 'BACK(target_a)', behavior: 'update_turn_parameters(target_a, 180.0)'}, sp: (156.608; 117.952), tp: (297.495; 371.074), label: (-263.427; 205.217), polyline: [ (1036.42; 468.787) ]}, Transition: {id: 'n0::n0::e0', source: 'n0::n0::n2', target: 'n0::n0::n0', sp: (0; 10), tp: (133.747; 0)}, Transition: {id: 'n0::n0::e1', source: 'n0::n0::n0', target: 'n0::n0::n1', action: {guard: 'completed()'}, sp: (133.747; 69.2119), tp: (133.747; 0), label: (1.57495; 11.3862)}, Transition: {id: 'n0::n0::e2', source: 'n0::n0::n1', target: 'n0::n0::n3', action: {guard: 'completed()'}, sp: (133.747; 69.2119), tp: (133.747; 0), label: (5.91246; 11.3862)}, Transition: {id: 'n0::e2', source: 'n0::n2', target: 'n0::n1', action: {trigger: 'TIME_TICK', guard: 'orientation_completed()', behavior: 'DISPATCH(cpu, 'ORIENTED') +DISPATCH(navigation, 'ORIENTED')'}, sp: (0; 419.174), tp: (156.608; 117.952), label: (-237.116; 17.6562), polyline: [ (1051; 526.111) ]}, Transition: {id: 'n0::n2::n0::e0', source: 'n0::n2::n0::n0', target: 'n0::n2::n0::n1', action: {guard: 'orientation.get_angular_velocity(AXIS_Z) < DW'}, sp: (179.158; 75.3372), tp: (179.158; 0), label: (11.4035; 9.5621)}, Transition: {id: 'n0::n2::n0::e1', source: 'n0::n2::n0::n1', target: 'n0::n2::n0::n0', action: {guard: 'orientation.get_angular_velocity(AXIS_Z) > DW'}, sp: (179.158; 0), tp: (179.158; 75.3372), label: (-299.03; -26.1772)}, Transition: {id: 'n0::n2::n0::e2', source: 'n0::n2::n0::n2', target: 'n0::n2::n0::n0', sp: (0; 10), tp: (179.158; 0)}, Transition: {id: 'n0::n2::e0', source: 'n0::n2::n2', target: 'n0::n2::n1', sp: (0; 10), tp: (196.8; 0)}, Transition: {id: 'n0::e3', source: 'n0::n0::n3', target: 'n0::n2', action: {guard: 'completed()'}, sp: (133.747; 69.2119), tp: (0; 604.347), label: (17.5826; 96.7526), polyline: [ (665.627; 711.284) ]}, Transition: {id: 'n0::n2::e1', source: 'n0::n2::n0', target: 'n0::n2::n1', action: {guard: 'is_target_dw()'}, sp: (196.8; 0), tp: (196.8; 75.3372), label: (-100.932; -30.9909)}, Transition: {id: 'n0::n2::e2', source: 'n0::n2::n1', target: 'n0::n2::n0', action: {guard: 'not is_target_dw()'}, sp: (196.8; 75.3372), tp: (196.8; 0), label: (9.66948; 13.8096)}}}} diff --git a/tests/19-legacy-geometry.cpp b/tests/19-legacy-geometry.cpp new file mode 100644 index 0000000..db16c73 --- /dev/null +++ b/tests/19-legacy-geometry.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", formatLegacyYED); + 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/19-legacy-geometry.test-input.graphml b/tests/19-legacy-geometry.test-input.graphml new file mode 100644 index 0000000..beaf32e --- /dev/null +++ b/tests/19-legacy-geometry.test-input.graphml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + node 0 + + + + + + + + + + + + + + parent 0 + + + + + + + + + + + + + + + + + + + + + + node 0-0 + + + + + + + + + + + + + + parent 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + node 0-0-0 + + + + + + + + + + + + + + + + + + + node 0-0-1 + + + + + + + + + + + + + + + + + + node 0-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LABEL + + + + + + + + + diff --git a/tests/19-output.graphml b/tests/19-output.graphml new file mode 100644 index 0000000..a0e4ffc --- /dev/null +++ b/tests/19-output.graphml @@ -0,0 +1,114 @@ + + + Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + node 0 + + formal + CGML_META + standardVersion/ 1.0 + +name/ node 0 + +transitionOrder/ transitionFirst + +eventPropagation/ block + + + + + node 0 + + + + + + node 0-0 + + + + + + initial + + + + + + + node 0-0-0 + + + + + + node 0-0-1 + + + + + + + + node 0-1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LABEL/ + + + + + + + + + + + + diff --git a/tests/19-output.txt b/tests/19-output.txt new file mode 100644 index 0000000..2cdb686 --- /dev/null +++ b/tests/19-output.txt @@ -0,0 +1 @@ +Document: {id: '', name: 'node 0', format: 'yEd Ostranna', meta: {standard version: '1.0', name: 'node 0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'node 0', elements: {Composite State: {id: 'n0', name: 'node 0', geometry: (-5; -5; 1000; 450), elements: {Composite State: {id: 'n0::n0', name: 'node 0-0', geometry: (55; 55; 600; 300), elements: {Initial: {id: 'n0::n0::n0', name: '', geometry: (200; 70)}, Simple State: {id: 'n0::n0::n1', name: 'node 0-0-0', geometry: (50; 100; 300; 150)}, Simple State: {id: 'n0::n0::n2', name: 'node 0-0-1', geometry: (450; 100; 150; 150)}}}, Simple State: {id: 'n0::n1', name: 'node 0-1', geometry: (805; 155; 150; 150)}}}, Transition: {id: 'n0::n0::e0', source: 'n0::n0::n1', target: 'n0::n0::n1', sp: (0; 75), tp: (150; 150), polyline: [ (75; 225), (75; 325), (250; 325) ]}, Transition: {id: 'n0::n0::e1', source: 'n0::n0::n0', target: 'n0::n0::n1', sp: (0; 10), tp: (150; 0)}, Transition: {id: 'n0::n0::e2', source: 'n0::n0::n1', target: 'n0::n0::n2', action: {trigger: 'LABEL'}, sp: (300; 105), tp: (0; 105), label: (0; 45)}}}} diff --git a/tests/20-legacy-geometry2.cpp b/tests/20-legacy-geometry2.cpp new file mode 100644 index 0000000..db16c73 --- /dev/null +++ b/tests/20-legacy-geometry2.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", formatLegacyYED); + 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/20-legacy-geometry2.test-input.graphml b/tests/20-legacy-geometry2.test-input.graphml new file mode 100644 index 0000000..f4d5c01 --- /dev/null +++ b/tests/20-legacy-geometry2.test-input.graphml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + parent + + + + + + + + + + + + + + parent 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + node 0 + + + + + + + + + + + + + + + + + + + node 1 + + + + + + + + + + + + + + + + node 2 + + + + + + + + + + + + + + + + node 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/20-output.graphml b/tests/20-output.graphml new file mode 100644 index 0000000..ff1de48 --- /dev/null +++ b/tests/20-output.graphml @@ -0,0 +1,111 @@ + + + Cyberiada-GraphML-1.0 + + + + + + + + + + + + + + + + + + + + + + parent + + formal + CGML_META + standardVersion/ 1.0 + +name/ parent + +transitionOrder/ transitionFirst + +eventPropagation/ block + + + + + parent + + + + + + initial + + + + + + + node 0 + + + + + + node 1 + + + + + + node 2 + + + + + + node 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/20-output.txt b/tests/20-output.txt new file mode 100644 index 0000000..67a0ba4 --- /dev/null +++ b/tests/20-output.txt @@ -0,0 +1 @@ +Document: {id: '', name: 'parent', format: 'yEd Ostranna', meta: {standard version: '1.0', name: 'parent', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G', name: 'parent', elements: {Composite State: {id: 'n0', name: 'parent', geometry: (0; 0; 800; 800), elements: {Initial: {id: 'n0::n0', name: '', geometry: (200; 200)}, Simple State: {id: 'n0::n1', name: 'node 0', geometry: (325; 325; 150; 150)}, Simple State: {id: 'n0::n2', name: 'node 1', geometry: (525; 125; 150; 150)}, Simple State: {id: 'n0::n3', name: 'node 2', geometry: (525; 525; 150; 150)}, Simple State: {id: 'n0::n4', name: 'node 3', geometry: (125; 525; 150; 150)}}}, Transition: {id: 'n0::e0', source: 'n0::n0', target: 'n0::n1', sp: (7.07107; 7.07107), tp: (0; 0)}, Transition: {id: 'n0::e1', source: 'n0::n1', target: 'n0::n2', sp: (150; 0), tp: (0; 150)}, Transition: {id: 'n0::e2', source: 'n0::n3', target: 'n0::n1', sp: (0; 0), tp: (150; 150)}, Transition: {id: 'n0::e3', source: 'n0::n4', target: 'n0::n1', sp: (150; 0), tp: (0; 150)}}}}