Do not match msg separator as constant value
This commit is contained in:
parent
7bbc2914c4
commit
75d98df4bf
@ -44,7 +44,7 @@ comment
|
||||
= r'#[^\n]*'
|
||||
|
||||
const_dcl
|
||||
= 'string' identifier '=' r'[^\n]+'
|
||||
= 'string' identifier r'=(?!={79}\n)' r'[^\n]+'
|
||||
/ type_spec identifier '=' integer_literal
|
||||
|
||||
field_dcl
|
||||
|
||||
@ -45,6 +45,15 @@ uint64[3] Header
|
||||
uint32 static = 42
|
||||
"""
|
||||
|
||||
CSTRING_CONFUSION_MSG = """
|
||||
std_msgs/Header header
|
||||
string s
|
||||
|
||||
================================================================================
|
||||
MSG: std_msgs/Header
|
||||
time time
|
||||
"""
|
||||
|
||||
RELSIBLING_MSG = """
|
||||
Header header
|
||||
Other other
|
||||
@ -144,6 +153,18 @@ def test_parse_multi_msg():
|
||||
assert consts == [('static', 'uint32', 42)]
|
||||
|
||||
|
||||
def test_parse_cstring_confusion():
|
||||
"""Test if msg separator is confused with const string."""
|
||||
ret = get_types_from_msg(CSTRING_CONFUSION_MSG, 'test_msgs/msg/Foo')
|
||||
assert len(ret) == 2
|
||||
assert 'test_msgs/msg/Foo' in ret
|
||||
assert 'std_msgs/msg/Header' in ret
|
||||
consts, fields = ret['test_msgs/msg/Foo']
|
||||
assert consts == []
|
||||
assert fields[0][1][1] == 'std_msgs/msg/Header'
|
||||
assert fields[1][1][1] == 'string'
|
||||
|
||||
|
||||
def test_parse_relative_siblings_msg():
|
||||
"""Test relative siblings with msg parser."""
|
||||
ret = get_types_from_msg(RELSIBLING_MSG, 'test_msgs/msg/Foo')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user