ZeroTierOne/zeroidc/vendor/serde_with/tests/json.rs
Grant Limberg a59626c971
Bump zeroidc dependencies (#1847)
openidconnect -> 2.5
base64 -> 0.21
url -> 2.3
bytes -> 1.3
2023-01-12 13:24:58 -08:00

41 lines
958 B
Rust

#![allow(
// clippy is broken and shows wrong warnings
// clippy on stable does not know yet about the lint name
unknown_lints,
// https://github.com/rust-lang/rust-clippy/issues/8867
clippy::derive_partial_eq_without_eq,
)]
mod utils;
use crate::utils::is_equal;
use expect_test::expect;
use serde::{Deserialize, Serialize};
use serde_with::{json::JsonString, serde_as, DisplayFromStr};
#[test]
fn test_nested_json() {
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Struct {
#[serde_as(as = "JsonString")]
value: Nested,
}
#[serde_as]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Nested {
#[serde_as(as = "DisplayFromStr")]
value: u32,
}
is_equal(
Struct {
value: Nested { value: 444 },
},
expect![[r#"
{
"value": "{\"value\":\"444\"}"
}"#]],
);
}