8fba2f737a
A union's 'discriminator' must name one of the common members. QAPISchemaVariants.check() looks it up by its c_name(), then checks the name matches exactly (because c_name() is not injective). Tests union-base-empty and union-invalid-discriminator both cover the case where lookup fails. Repurpose the latter to cover the case where it succeeds and the name check fails. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-10-armbru@redhat.com Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message typo fixed]
15 lines
341 B
JSON
15 lines
341 B
JSON
{ 'enum': 'TestEnum',
|
|
'data': [ 'value1', 'value2' ] }
|
|
|
|
{ 'struct': 'TestTypeA',
|
|
'data': { 'string': 'str' } }
|
|
|
|
{ 'struct': 'TestTypeB',
|
|
'data': { 'integer': 'int' } }
|
|
|
|
{ 'union': 'TestUnion',
|
|
'base': { 'type-tag': 'TestEnum' },
|
|
'discriminator': 'type_tag',
|
|
'data': { 'value1': 'TestTypeA',
|
|
'value2': 'TestTypeB' } }
|