CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
135 stars 74 forks source link

XmlSubtreeCodec fails encode leaf-list data #1045

Closed ygorelik closed 2 years ago

ygorelik commented 3 years ago

Current Behavior

XmlSubtreeCodec fails encode leaf-list data.

How to reproduce

Add and run the following test case:

TEST_CASE( "xml_codec_decode_leaflist" )
{
    auto repo = path::Repository{TEST_HOME};
    std::vector<path::Capability> empty_caps;
    auto root = repo.create_root_schema(empty_caps);
    XmlSubtreeCodec xml_codec{};

    auto runner = ydktest_sanity::Runner();
    runner.ytypes->built_in_t->llstring.append("abc");
    runner.ytypes->built_in_t->llstring.append("klm");
    runner.ytypes->built_in_t->llstring.append("xyz");
    auto xml = xml_codec.encode(runner, *root);
    cout << xml << endl;
}

Observe the output:

<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <llstring/>
      <llstring/>
      <llstring/>
    </built-in-t>
  </ytypes>
</runner>

Note, all leaf-list values are empty.

System Information

YDK-0.8.5

ygorelik commented 3 years ago

After fixing the code, got the following unit test result:

<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
  <ytypes>
    <built-in-t>
      <llstring>abc</llstring>
      <llstring>klm</llstring>
      <llstring>xyz</llstring>
    </built-in-t>
  </ytypes>
</runner>