ruma_common/serde/test.rs
1//! Helpers for tests
2
3use std::fmt::Debug;
4
5use serde::{de::DeserializeOwned, Serialize};
6
7/// Assert that serialization of `de` results in `se` and deserialization of `se` results in `de`.
8pub fn serde_json_eq<T>(de: T, se: serde_json::Value)
9where
10 T: Clone + Debug + PartialEq + Serialize + DeserializeOwned,
11{
12 assert_eq!(se, serde_json::to_value(de.clone()).unwrap());
13 assert_eq!(de, serde_json::from_value(se).unwrap());
14}