mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-30 16:30:49 +08:00
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:
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user