Debian Codegraph @

tests/integration/jiff.rs

raw symbols SCIP
1 use crate::prelude::*;
2 use jiff02::civil::{Date, DateTime, Time};
3 use jiff02::{SignedDuration, Span, Timestamp, Zoned};
4
5 #[derive(JsonSchema, Serialize, Deserialize)]
6 struct JiffTypes {
7 date_time_ts: Timestamp,
8 date_time_zoned: Zoned,
9 naive_date: Date,
10 naive_date_time: DateTime,
11 naive_time: Time,
12 duration: SignedDuration,
13 span: Span,
14 }
15
16 #[test]
17 fn jiff() {
18 test!(JiffTypes).assert_snapshot();
19
20 test!(Timestamp)
21 .assert_allows_ser_roundtrip_default()
22 .assert_matches_de_roundtrip(arbitrary_values());
23
24 test!(Zoned)
25 .assert_allows_ser_roundtrip_default()
26 .assert_matches_de_roundtrip(arbitrary_values_except(
27 Value::is_string,
28 "Custom format 'zoned-date-time', so arbitrary strings technically allowed by schema",
29 ));
30
31 test!(Date)
32 .assert_allows_ser_roundtrip_default()
33 .assert_matches_de_roundtrip(arbitrary_values());
34
35 test!(DateTime)
36 .assert_allows_ser_roundtrip_default()
37 .assert_matches_de_roundtrip(arbitrary_values_except(
38 Value::is_string,
39 "Custom format 'partial-date-time', so arbitrary strings technically allowed by schema",
40 ));
41
42 test!(Time)
43 .assert_allows_ser_roundtrip_default()
44 .assert_matches_de_roundtrip(arbitrary_values_except(
45 Value::is_string,
46 "Custom format 'date-time', so arbitrary strings technically allowed by schema",
47 ));
48
49 test!(SignedDuration)
50 .assert_allows_ser_roundtrip_default()
51 .assert_matches_de_roundtrip(arbitrary_values());
52
53 test!(Span)
54 .assert_allows_ser_roundtrip_default()
55 .assert_matches_de_roundtrip(arbitrary_values());
56 }