Commit 009190c5 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Keep dash in VN parsed strings

parent 268ab8ee
......@@ -137,19 +137,19 @@ VALUE_LIST.setParseAction(lambda s, l, t: [t.asList()])
def parseChoiceValue(s, l, t):
''' Parsing CHOICE '''
choice = t[0].replace('-', '_')
choice = t[0]
return {'Choice': choice, choice: t[2]}
choiceValue.setParseAction(parseChoiceValue)
def parseValueReference(s, l, t):
''' Parsing ENUMERATED Id '''
value = t[0]#.replace('-', '_')
value = t[0]
return {'Enum': value}
valuereference.setParseAction(parseValueReference)
namedValue.setParseAction(lambda s, l, t: {t[0].replace('-', '_'): t[1]})
namedValue.setParseAction(lambda s, l, t: {t[0]: t[1]})
FloatingPointLiteral.setParseAction(lambda s, l, t: float(t[0]))
INT.setParseAction(lambda s, l, t: int(t[0]))
TRUE.setParseAction(lambda s, l, t: True)
......@@ -181,17 +181,17 @@ def toASN1ValueNotation(val):
result = ''
if isinstance(val, dict):
if 'Choice' in val:
result += val['Choice'].replace('_', '-').strip() + ':'
result += val['Choice'].strip() + ':'
result += toASN1ValueNotation(val[val['Choice']])
elif 'Enum' in val:
result += unicode(val['Enum']).replace('_', '-').strip()
result += unicode(val['Enum']).strip()
else: # SEQUENCE and SET
result += ' { '
needsComa = False
for seqElem in val:
if needsComa:
result += ', '
result += seqElem.replace('_', '-').strip() + ' '
result += seqElem.strip() + ' '
result += toASN1ValueNotation(val[seqElem])
needsComa = True
result += ' }'
......
......@@ -78,7 +78,7 @@ def test_random_simpleseq(qtbot):
def test_random_simplechoice(qtbot):
''' Test CHOICE. '''
typeName = "Type-SingleChoice"
for i in range(1000):
for i in range(100):
result = compute_random_value(pool[typeName], pool)
if 'choice-B' in result:
assert 'TRUE' in result or 'FALSE' in result
......@@ -93,7 +93,7 @@ def test_random_simplechoice(qtbot):
def test_random_simpleseqof(qtbot):
''' Test SEQOF '''
typeName = "Type-SingleSeqOf"
for i in range(1000):
for i in range(100):
result = compute_random_value(pool[typeName], pool)
value = parse_gser('result', result)['result']
assert 0 <= len(value) <= 5
......@@ -104,7 +104,7 @@ def test_random_simpleseqof(qtbot):
def test_random_mydata(qtbot):
''' Test more complex sequence '''
typeName = "MyData"
for i in range(1000):
for i in range(10):
result = compute_random_value(pool[typeName], pool)
value = parse_gser('result', result)['result']
assert type(value) is list and 1 <= len(value) <= 10
......@@ -118,7 +118,7 @@ def test_random_mydata(qtbot):
def test_random_seq2(qtbot):
''' Test more complex sequence '''
typeName = "Type-Seq"
for i in range(1000):
for i in range(10):
result = compute_random_value(pool[typeName], pool)
value = parse_gser('result', result)['result']
assert 'item-a' in value and 'item-b' in value and 'item-C' in value \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment