Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit reprcode change to the same reprcode #110

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,9 @@ object_vector parse_objects( const object_template& tmpl,
* certain codes (ident -> ascii), but is no need for now
*/

if (flags.reprc) {
const auto msg = "count ({}) and representation code "
"({}) changed, but value is not explicitly set";
if (flags.reprc && attr.reprc != template_attr.reprc) {
const auto msg = "count ({}) isn't 0 and representation "
"code ({}) changed, but value is not explicitly set";
const auto code = static_cast< int >(attr.reprc);
throw std::runtime_error(fmt::format(msg, count, code));
}
Expand Down
1 change: 1 addition & 0 deletions python/data/parse/objattr/repeat-default-novalue.dlis.part
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.default attr units
17 changes: 17 additions & 0 deletions python/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,23 @@ def test_different_repcode_no_value(tmpdir, merge):
assert "value is not explicitly set" in str(excinfo.value)


def test_same_as_default_no_value(tmpdir, merge):
path = os.path.join(str(tmpdir), 'same-as-default-but-no-value.dlis')
content = [
'data/parse/start.dlis.part',
'data/parse/template/default.dlis.part',
'data/parse/object/object.dlis.part',
'data/parse/objattr/repeat-default-novalue.dlis.part'
]
merge(path, content)

with dlisio.load(path) as f:
key = dlisio.core.fingerprint('VERY_MUCH_TESTY_SET', 'OBJECT', 1, 1)
obj = f.objects[key]
attr = obj.attic['DEFAULT_ATTRIBUTE']
assert attr == [-0.75, 10.0]


@pytest.mark.future_test_attributes
def test_novalue_less_count(tmpdir, merge):
path = os.path.join(str(tmpdir), 'novalue-less-count.dlis')
Expand Down