| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | use chrono04rust-analyzer cargo chrono 0.4.45 crate/::{preluderust-analyzer cargo chrono 0.4.45 prelude/::*, TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#}; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:)] |
| 5 | struct ChronoTypesrust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes# { |
| 6 | weekdayrust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#weekday.: Weekdayrust-analyzer cargo chrono 0.4.45 weekday/Weekday#, |
| 7 | date_timerust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#date_time.: DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#>, |
| 8 | naive_daterust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#naive_date.: NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#, |
| 9 | naive_date_timerust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#naive_date_time.: NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#, |
| 10 | naive_timerust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#naive_time.: NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, |
| 11 | time_deltarust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#time_delta.: TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#, |
| 12 | } |
| 13 | |
| 14 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 15 | fn chronorust-analyzer cargo schemars 1.2.2 chrono/chrono().() { |
| 16 | testrust-analyzer cargo schemars 1.2.2 test!!(ChronoTypesrust-analyzer cargo schemars 1.2.2 chrono/ChronoTypes#).assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().(); |
| 17 | |
| 18 | testrust-analyzer cargo schemars 1.2.2 test!!(Weekdayrust-analyzer cargo chrono 0.4.45 weekday/Weekday#) |
| 19 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([Weekdayrust-analyzer cargo chrono 0.4.45 weekday/Weekday#::Monrust-analyzer cargo chrono 0.4.45 weekday/Weekday#Mon#]) |
| 20 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 21 | |
| 22 | testrust-analyzer cargo schemars 1.2.2 test!!(DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#>) |
| 23 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 24 | // JSON Schema only allows dates with 4-digit years |
| 25 | // .assert_allows_ser_roundtrip([DateTime::<Utc>::MIN_UTC, DateTime::<Utc>::MAX_UTC]) |
| 26 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 27 | |
| 28 | testrust-analyzer cargo schemars 1.2.2 test!!(NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#) |
| 29 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 30 | // JSON Schema only allows dates with 4-digit years |
| 31 | // .assert_allows_ser_roundtrip([NaiveDate::MIN, NaiveDate::MAX]) |
| 32 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 33 | |
| 34 | testrust-analyzer cargo schemars 1.2.2 test!!(NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#) |
| 35 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 36 | // JSON Schema only allows dates with 4-digit years |
| 37 | // .assert_allows_ser_roundtrip([NaiveDateTime::MIN, NaiveDateTime::MAX]) |
| 38 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_values_exceptrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values_except().( |
| 39 | Valuerust-analyzer cargo serde_json 1.0.151 value/Value#::is_stringrust-analyzer cargo serde_json 1.0.151 value/impl#[Value]is_string()., |
| 40 | "Custom format 'partial-date-time', so arbitrary strings technically allowed by schema", |
| 41 | )); |
| 42 | |
| 43 | testrust-analyzer cargo schemars 1.2.2 test!!(NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#) |
| 44 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 45 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#::MINrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime]MIN., NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#::MAXrust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]MAX..timerust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]time().()]) |
| 46 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_values_exceptrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values_except().( |
| 47 | Valuerust-analyzer cargo serde_json 1.0.151 value/Value#::is_stringrust-analyzer cargo serde_json 1.0.151 value/impl#[Value]is_string()., |
| 48 | "Custom format 'date-time', so arbitrary strings technically allowed by schema", |
| 49 | )); |
| 50 | |
| 51 | testrust-analyzer cargo schemars 1.2.2 test!!(TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#) |
| 52 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 53 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#::MINrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]MIN., TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#::MAXrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]MAX.]) |
| 54 | .assert_rejects_derust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_rejects_de().([jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!([0, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1]), jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!([0, 1_000_000_000])]) |
| 55 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 56 | } |