chaokunyang commented on code in PR #3735:
URL: https://github.com/apache/fory/pull/3735#discussion_r3377821311
##########
compiler/fory_compiler/tests/test_generated_code.py:
##########
@@ -1044,6 +1044,48 @@ def
test_cpp_generator_supports_decimal_fields_and_unions():
assert "(amount, fory::serialization::Decimal, fory::F(1))" in cpp_output
+def test_cpp_nested_container_ref_uses_correct_pointer_type():
+ schema = parse_fdl(
+ dedent(
+ """
+ package gen;
+
+ message Node {
+ string value = 1;
+ }
+
+ message Request {
+ list<list<ref Node>> groups = 1;
+ map<string, map<string, ref Node>> nodes = 2;
+ list<list<ref(weak=true) Node>> weak_groups = 3;
+ map<string, map<string, ref(weak=true) Node>> weak_nodes = 4;
+ }
+ """
+ )
+ )
+
+ cpp_output = render_files(generate_files(schema, CppGenerator))
+ assert "std::vector<std::vector<std::shared_ptr<Node>>> groups_;" in
cpp_output
+ assert "std::vector<std::vector<Node>> groups_;" not in cpp_output
+ assert (
+ "std::map<std::string, std::map<std::string, std::shared_ptr<Node>>>
nodes_;"
+ in cpp_output
+ )
+ assert (
+ "std::vector<std::vector<fory::serialization::SharedWeak<Node>>>
weak_groups_;"
+ in cpp_output
+ )
+ assert (
+ "std::map<std::string, "
Review Comment:
C++ should use unorderd_map, could you open a new pr for this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]