mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
xml: EnumVariant variant_names for untagged enums
This commit is contained in:
@@ -10,7 +10,12 @@ pub const NS_CALENDARSERVER: Namespace = Namespace(b"http://calendarserver.org/n
|
||||
pub const NS_NEXTCLOUD: Namespace = Namespace(b"http://nextcloud.com/ns");
|
||||
|
||||
#[derive(EnumVariants)]
|
||||
pub enum CalendarProp {
|
||||
enum ExtensionProp {
|
||||
Hello,
|
||||
}
|
||||
|
||||
#[derive(EnumVariants)]
|
||||
enum CalendarProp {
|
||||
// WebDAV (RFC 2518)
|
||||
#[xml(ns = "NS_DAV")]
|
||||
Displayname(Option<String>),
|
||||
@@ -23,7 +28,7 @@ pub enum CalendarProp {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum_variants() {
|
||||
fn test_enum_tagged_variants() {
|
||||
assert_eq!(
|
||||
CalendarProp::TAGGED_VARIANTS,
|
||||
&[
|
||||
@@ -34,3 +39,24 @@ fn test_enum_variants() {
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(EnumVariants)]
|
||||
#[xml(untagged)]
|
||||
enum UnionProp {
|
||||
Calendar(CalendarProp),
|
||||
Extension(ExtensionProp),
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum_untagged_variants() {
|
||||
assert_eq!(
|
||||
UnionProp::variant_names(),
|
||||
vec![
|
||||
(Some(NS_DAV), "displayname"),
|
||||
(Some(NS_DAV), "getcontenttype"),
|
||||
(Some(NS_DAV), "principal-URL"),
|
||||
(None, "topic"),
|
||||
(None, "hello"),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user