| 1 | #![allow(clippy::disallowed_names)] |
| 2 | |
| 3 | #[cfg(feature = "arrayvec07")] |
| 4 | mod arrayvec; |
| 5 | mod attr_order; |
| 6 | mod bound; |
| 7 | #[cfg(feature = "bytes1")] |
| 8 | mod bytes; |
| 9 | #[cfg(feature = "chrono04")] |
| 10 | mod chrono; |
| 11 | mod contract; |
| 12 | mod crate_alias; |
| 13 | #[cfg(any(feature = "rust_decimal1", feature = "bigdecimal04"))] |
| 14 | mod decimal; |
| 15 | mod default; |
| 16 | mod deprecated; |
| 17 | mod docs; |
| 18 | #[cfg(feature = "either1")] |
| 19 | mod either; |
| 20 | mod enum_repr; |
| 21 | mod enums; |
| 22 | mod enums_deny_unknown_fields; |
| 23 | mod enums_flattened; |
| 24 | mod enums_option_flattened; |
| 25 | mod enums_ref_variants; |
| 26 | mod enums_untagged_variant; |
| 27 | mod examples; |
| 28 | mod extend; |
| 29 | mod flatten; |
| 30 | mod from_into; |
| 31 | mod from_value; |
| 32 | mod garde; |
| 33 | #[cfg(feature = "indexmap2")] |
| 34 | mod indexmap; |
| 35 | mod inline_subschemas; |
| 36 | #[cfg(feature = "jiff02")] |
| 37 | mod jiff; |
| 38 | mod macros; |
| 39 | mod map; |
| 40 | mod remote_derive; |
| 41 | mod same_name; |
| 42 | mod schema_name; |
| 43 | mod schema_with; |
| 44 | #[cfg(feature = "semver1")] |
| 45 | mod semver; |
| 46 | mod settings; |
| 47 | mod skip; |
| 48 | #[cfg(feature = "smallvec1")] |
| 49 | mod smallvec; |
| 50 | #[cfg(any(feature = "smol_str02", feature = "smol_str03"))] |
| 51 | mod smol_str; |
| 52 | mod std_types; |
| 53 | mod structs; |
| 54 | mod transform; |
| 55 | mod transparent; |
| 56 | mod unset; |
| 57 | #[cfg(feature = "url2")] |
| 58 | mod url; |
| 59 | #[cfg(feature = "uuid1")] |
| 60 | mod uuid; |
| 61 | mod validator; |
| 62 | |
| 63 | mod prelude { |
| 64 | pub(crate) use crate::test; |
| 65 | pub(crate) use crate::test_helper::{arbitrary_values, arbitrary_values_except}; |
| 66 | pub(crate) use schemars::JsonSchema; |
| 67 | pub(crate) use serde::{Deserialize, Serialize}; |
| 68 | pub(crate) use serde_json::{json, Value}; |
| 69 | } |
| 70 | |
| 71 | mod test_helper; |
| 72 | |
| 73 | #[macro_export] |
| 74 | macro_rules! test_name { |
| 75 | () => {{ |
| 76 | fn f() {} |
| 77 | fn type_name_of_val<T>(_: T) -> &'static str { |
| 78 | core::any::type_name::<T>() |
| 79 | } |
| 80 | let test_fn_name = type_name_of_val(f) |
| 81 | .trim_end_matches("::f") |
| 82 | .split("::") |
| 83 | .last() |
| 84 | .unwrap(); |
| 85 | format!("{}~{}", core::file!(), test_fn_name) |
| 86 | }}; |
| 87 | } |
| 88 | |
| 89 | #[macro_export] |
| 90 | macro_rules! test { |
| 91 | ($type:ty, $settings:expr) => { |
| 92 | $crate::test_helper::TestHelper::<$type>::new($crate::test_name!(), $settings) |
| 93 | }; |
| 94 | ($type:ty) => { |
| 95 | test!($type, schemars::generate::SchemaSettings::default()) |
| 96 | }; |
| 97 | (value: $value:expr, $settings:expr) => { |
| 98 | $crate::test_helper::TestHelper::new_for_value($crate::test_name!(), $settings, $value) |
| 99 | }; |
| 100 | (value: $value:expr) => { |
| 101 | test!(value: $value, schemars::generate::SchemaSettings::default()) |
| 102 | }; |
| 103 | } |