Parse empty msg definitions

This commit is contained in:
Marko Durkovic 2021-11-08 15:11:39 +01:00
parent c55e81f375
commit af848eb3d2
2 changed files with 8 additions and 2 deletions

View File

@ -30,7 +30,7 @@ specification
= msgdef (msgsep msgdef)*
msgdef
= r'MSG:\s' scoped_name definition+
= r'MSG:\s' scoped_name definition*
msgsep
= r'================================================================================'

View File

@ -118,10 +118,16 @@ module test_msgs {
"""
def test_parse_empty_msg():
"""Test msg parser with empty message."""
ret = get_types_from_msg('', 'std_msgs/msg/Empty')
assert ret == {'std_msgs/msg/Empty': ([], [])}
def test_parse_msg():
"""Test msg parser."""
with pytest.raises(TypesysError, match='Could not parse'):
get_types_from_msg('', 'test_msgs/msg/Foo')
get_types_from_msg('invalid', 'test_msgs/msg/Foo')
ret = get_types_from_msg(MSG, 'test_msgs/msg/Foo')
assert 'test_msgs/msg/Foo' in ret
consts, fields = ret['test_msgs/msg/Foo']