Add tests for tuple enum variants
This commit is contained in:
parent
c2e8389e93
commit
07f4f68a02
4 changed files with 40 additions and 4 deletions
|
@ -9,6 +9,7 @@ pub enum External {
|
||||||
StringMap(Map<String, String>),
|
StringMap(Map<String, String>),
|
||||||
Struct { foo: i32, bar: bool },
|
Struct { foo: i32, bar: bool },
|
||||||
UnitTwo,
|
UnitTwo,
|
||||||
|
Tuple(i32, bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -35,7 +36,8 @@ fn enum_internal_tag() -> TestResult {
|
||||||
pub enum Untagged {
|
pub enum Untagged {
|
||||||
UnitOne,
|
UnitOne,
|
||||||
StringMap(Map<String, String>),
|
StringMap(Map<String, String>),
|
||||||
Struct{ foo: i32, bar: bool }
|
Struct { foo: i32, bar: bool },
|
||||||
|
Tuple(i32, bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -44,6 +44,27 @@
|
||||||
"required": [
|
"required": [
|
||||||
"struct"
|
"struct"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"tuple": {
|
||||||
|
"type": "array",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"maxItems": 2,
|
||||||
|
"minItems": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"tuple"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -25,6 +25,19 @@
|
||||||
"bar",
|
"bar",
|
||||||
"foo"
|
"foo"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"maxItems": 2,
|
||||||
|
"minItems": 2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -105,7 +105,7 @@ fn schema_for_enum(variants: &[Variant], cattrs: &attr::Container) -> TokenStrea
|
||||||
EnumTag::External => schema_for_external_tagged_enum(variants, cattrs),
|
EnumTag::External => schema_for_external_tagged_enum(variants, cattrs),
|
||||||
EnumTag::None => schema_for_untagged_enum(variants, cattrs),
|
EnumTag::None => schema_for_untagged_enum(variants, cattrs),
|
||||||
EnumTag::Internal { tag } => schema_for_internal_tagged_enum(variants, cattrs, tag),
|
EnumTag::Internal { tag } => schema_for_internal_tagged_enum(variants, cattrs, tag),
|
||||||
_ => unimplemented!("Adjacent/internal tagged enums not yet supported."),
|
EnumTag::Adjacent => unimplemented!("Adjacent tagged enums not yet supported."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue