diff --git a/tests/530_untagged_union.rs b/tests/530_untagged_union.rs new file mode 100644 index 000000000..37e8ffe50 --- /dev/null +++ b/tests/530_untagged_union.rs @@ -0,0 +1,21 @@ +use std::ops::Bound; + +#[derive(serde::Deserialize, serde::Serialize, PartialEq, Eq, Debug)] +#[serde(untagged)] +enum EitherInterval { + B(Interval), + D(V, Option), +} + +type Interval = (Bound, Bound); + +#[test] +fn serde_roundtrip() { + let interval = EitherInterval::B((Bound::Excluded(0u8), Bound::Unbounded)); + + let ron: String = ron::ser::to_string(&interval).unwrap(); + assert_eq!(ron, "(Excluded(0),Unbounded)"); + + let de = ron::de::from_str(&ron).unwrap(); + assert_eq!(interval, de); +}