test: add roundtrip::json_value

Adds a roundtrip helper for going to/from a json value. This can have
slightly different semantics in comparison to/from a json string.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-12-08 15:17:19 +00:00
parent 1316a13dfc
commit 9d137e5e7d
+10
View File
@@ -20,6 +20,16 @@ where
)
}
pub fn json_value<A>(a: A)
where
for<'de> A: Clone + Debug + PartialEq + serde::Serialize + serde::Deserialize<'de>,
{
assert_eq!(
a.clone(),
serde_json::from_value(serde_json::to_value(a).unwrap()).unwrap()
)
}
pub fn cbor<A>(a: A)
where
for<'de> A: Debug + PartialEq + minicbor::Encode + minicbor::Decode<'de>,