#![cfg(feature = "serde")] use std::{collections::HashMap, hash::Hash}; use quickcheck_macros::quickcheck; use serde::{Deserialize, Serialize}; type BoxString = strumbra::BoxString<4>; type ArcString = strumbra::ArcString<4>; type RcString = strumbra::RcString<4>; #[derive(Serialize, Deserialize)] struct Test { raw: T, vec: Vec, map: HashMap, } #[quickcheck] #[cfg_attr(miri, ignore)] fn serde(raw: String, vec: Vec, map: HashMap) { let wanted = Test { raw, vec, map }; let json = serde_json::to_string(&wanted).unwrap(); let boxed = serde_json::from_str::>(&json).unwrap(); let arc = serde_json::from_str::>(&json).unwrap(); let rc = serde_json::from_str::>(&json).unwrap(); assert_eq!(wanted.raw, boxed.raw); assert_eq!(wanted.raw, arc.raw); assert_eq!(wanted.raw, rc.raw); assert_eq!(wanted.vec, boxed.vec); assert_eq!(wanted.vec, arc.vec); assert_eq!(wanted.vec, rc.vec); for (k, v) in wanted.map { let boxed_v = boxed.map.get(k.as_str()).expect("A existing value"); let arc_v = arc.map.get(k.as_str()).expect("A existing value"); let rc_v = rc.map.get(k.as_str()).expect("A existing value"); assert_eq!(&v, boxed_v); assert_eq!(&v, arc_v); assert_eq!(&v, rc_v); } }