From 14aa061d0bd4cbc352a64981018ea4ba0df7fbdd Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sat, 17 Aug 2024 23:08:26 -0500 Subject: [PATCH 1/2] Fixing the category key when loading proto files --- xml_converter/integration_tests/run_tests.py | 2 ++ .../display_name_valid/input/pack/xml_file.xml | 16 ++++++++++++++++ .../output_proto/markers.bin | 7 +++++++ .../display_name_valid/output_xml/xml_file.xml | 18 ++++++++++++++++++ .../display_name_valid/testcase.yaml | 5 +++++ .../proto_type_valid/input/pack/markers.bin | 7 +++++++ .../proto_type_valid/output_proto/markers.bin | 7 +++++++ .../proto_type_valid/output_xml/xml_file.xml | 18 ++++++++++++++++++ .../test_cases/proto_type_valid/testcase.yaml | 5 +++++ xml_converter/src/packaging_protobin.cpp | 10 ++++++++-- 10 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 xml_converter/integration_tests/test_cases/display_name_valid/input/pack/xml_file.xml create mode 100644 xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin create mode 100644 xml_converter/integration_tests/test_cases/display_name_valid/output_xml/xml_file.xml create mode 100644 xml_converter/integration_tests/test_cases/display_name_valid/testcase.yaml create mode 100644 xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin create mode 100644 xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin create mode 100644 xml_converter/integration_tests/test_cases/proto_type_valid/output_xml/xml_file.xml create mode 100644 xml_converter/integration_tests/test_cases/proto_type_valid/testcase.yaml diff --git a/xml_converter/integration_tests/run_tests.py b/xml_converter/integration_tests/run_tests.py index dd4ad715..64589d29 100755 --- a/xml_converter/integration_tests/run_tests.py +++ b/xml_converter/integration_tests/run_tests.py @@ -118,6 +118,7 @@ def rebuild_xml_converter_binary() -> None: ################################################################################ line_patterns_to_ignore = [ r"^Loading taco pack .*$", + r"^Loading waypoint pack .*$", r"^The taco parse function took [0-9]+ milliseconds to run$", r"^The xml write function took [0-9]+ milliseconds to run$", r"^The protobuf read function took [0-9]+ milliseconds to run$", @@ -170,6 +171,7 @@ def main() -> bool: rawstdout, rawstderr, returncode = run_xml_converter( input_xml=testcase.xml_input_paths, + input_proto=testcase.proto_input_paths, output_xml=[xml_output_dir_path], output_proto=[proto_output_dir_path], ) diff --git a/xml_converter/integration_tests/test_cases/display_name_valid/input/pack/xml_file.xml b/xml_converter/integration_tests/test_cases/display_name_valid/input/pack/xml_file.xml new file mode 100644 index 00000000..651af9cb --- /dev/null +++ b/xml_converter/integration_tests/test_cases/display_name_valid/input/pack/xml_file.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin new file mode 100644 index 00000000..478c3f29 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin @@ -0,0 +1,7 @@ + +, + My Category 2B \Ï)Cf¦RC{ÔWCB(èÌ“^– +™ +Nested Level Onef +Nested Level Two3 +Nested Level Three 2B \Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B \Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B \Ï)Cf¦RC{ÔWCB,’§íj@: \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/display_name_valid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/display_name_valid/output_xml/xml_file.xml new file mode 100644 index 00000000..78dbad1a --- /dev/null +++ b/xml_converter/integration_tests/test_cases/display_name_valid/output_xml/xml_file.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/xml_converter/integration_tests/test_cases/display_name_valid/testcase.yaml b/xml_converter/integration_tests/test_cases/display_name_valid/testcase.yaml new file mode 100644 index 00000000..9510c793 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/display_name_valid/testcase.yaml @@ -0,0 +1,5 @@ +input_paths: + "pack": "xml" +expected_stdout: | +expected_stderr: | +expected_returncode: 0 diff --git a/xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin b/xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin new file mode 100644 index 00000000..478c3f29 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin @@ -0,0 +1,7 @@ + +, + My Category 2B \Ï)Cf¦RC{ÔWCB(èÌ“^– +™ +Nested Level Onef +Nested Level Two3 +Nested Level Three 2B \Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B \Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B \Ï)Cf¦RC{ÔWCB,’§íj@: \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin new file mode 100644 index 00000000..478c3f29 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin @@ -0,0 +1,7 @@ + +, + My Category 2B \Ï)Cf¦RC{ÔWCB(èÌ“^– +™ +Nested Level Onef +Nested Level Two3 +Nested Level Three 2B \Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B \Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B \Ï)Cf¦RC{ÔWCB,’§íj@: \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/proto_type_valid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/proto_type_valid/output_xml/xml_file.xml new file mode 100644 index 00000000..5e25a018 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/proto_type_valid/output_xml/xml_file.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/xml_converter/integration_tests/test_cases/proto_type_valid/testcase.yaml b/xml_converter/integration_tests/test_cases/proto_type_valid/testcase.yaml new file mode 100644 index 00000000..d87f4066 --- /dev/null +++ b/xml_converter/integration_tests/test_cases/proto_type_valid/testcase.yaml @@ -0,0 +1,5 @@ +input_paths: + "pack": "proto" +expected_stdout: | +expected_stderr: | +expected_returncode: 0 diff --git a/xml_converter/src/packaging_protobin.cpp b/xml_converter/src/packaging_protobin.cpp index 94cd27f8..282e0ff3 100644 --- a/xml_converter/src/packaging_protobin.cpp +++ b/xml_converter/src/packaging_protobin.cpp @@ -29,8 +29,10 @@ void parse_waypoint_categories( map* marker_categories, vector* parsed_pois, ProtoReaderState* state) { - full_category_name += proto_category.name(); - Category* this_category = &(*marker_categories)[full_category_name]; + + string category_name = normalize(proto_category.name()); + full_category_name += category_name; + Category* this_category = &(*marker_categories)[category_name]; this_category->parse_protobuf(proto_category, state); @@ -40,6 +42,7 @@ void parse_waypoint_categories( // TODO: The field category in Icon is being deprciated // This overwrites any icon.category with its position in the heirarchy icon->category.category = full_category_name; + icon->category_is_set = true; parsed_pois->push_back(icon); } for (int i = 0; i < proto_category.trail_size(); i++) { @@ -48,6 +51,7 @@ void parse_waypoint_categories( // TODO: The field category in Trail is being deprciated // This overwrites any trail.category with its position in the heirarchy trail->category.category = full_category_name; + trail->category_is_set = true; parsed_pois->push_back(trail); } @@ -216,10 +220,12 @@ void write_protobuf_file( Parseable* parsed_poi = (*parsed_pois)[i]; if (parsed_poi->classname() == "POI") { Icon* icon = dynamic_cast(parsed_poi); + // TODO(331): This is the wrong place to lowercase() the category and is hiding some crimes elsewhere category_to_pois[lowercase(icon->category.category)].push_back(parsed_poi); } else if (parsed_poi->classname() == "Trail") { Trail* trail = dynamic_cast(parsed_poi); + // TODO(331): This is the wrong place to lowercase() the category and is hiding some crimes elsewhere category_to_pois[lowercase(trail->category.category)].push_back(parsed_poi); } else { From 39963b328f067f6e07b161481e62c01d37f2d7ea Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Sun, 18 Aug 2024 16:25:54 -0500 Subject: [PATCH 2/2] fixing clang format issues --- xml_converter/src/packaging_protobin.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/xml_converter/src/packaging_protobin.cpp b/xml_converter/src/packaging_protobin.cpp index 282e0ff3..3fe1b03a 100644 --- a/xml_converter/src/packaging_protobin.cpp +++ b/xml_converter/src/packaging_protobin.cpp @@ -29,7 +29,6 @@ void parse_waypoint_categories( map* marker_categories, vector* parsed_pois, ProtoReaderState* state) { - string category_name = normalize(proto_category.name()); full_category_name += category_name; Category* this_category = &(*marker_categories)[category_name];