Skip to content

Commit

Permalink
Merge pull request #10 from leoetlino/yml-fix
Browse files Browse the repository at this point in the history
lib: Work around a ryml parsing issue for empty, tagged strings in maps
leoetlino authored Sep 19, 2020
2 parents 9bba3ab + 2fcde1d commit 9ed4634
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rapidyaml
23 changes: 23 additions & 0 deletions test/aamp/test_aamp_empty_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
import oead
from pathlib import Path


# Catches possible YAML parsing regressions such as empty, tagged strings being turned
# into tildes:
# https://github.com/biojppm/rapidyaml/commit/98d3d9763584313a#commitcomment-42460490
def test_aamp_empty_strings():
with (Path(__file__).parent / "test_empty_strings.yml").open("r") as test_yml:
yml_data = test_yml.read()
data: oead.aamp.ParameterIO = oead.aamp.ParameterIO.from_text(yml_data)
assert data.type == "oead_test"
assert data.version == 10

assert str(data.objects["TestContent"].params["Str64_empty"].v) == ""
assert str(data.objects["TestContent"].params["Str64_empty2"].v) == ""

text_serialized = data.to_text()
assert data == oead.aamp.ParameterIO.from_text(text_serialized)

bin_serialized = data.to_binary()
assert data == oead.aamp.ParameterIO.from_binary(bin_serialized)
9 changes: 9 additions & 0 deletions test/aamp/test_empty_strings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!io
version: 10
type: oead_test
param_root: !list
objects:
TestContent: !obj
Str64_empty: !str64 ''
Str64_empty2: !str64
lists: {}

0 comments on commit 9ed4634

Please sign in to comment.