serde_json_diagnostics/
lib.rs1pub use de::{from_reader, from_slice, from_str};
15pub use error::{ErrorDiagnostic, Result};
16
17mod de;
18mod error;
19mod path;
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn result_type_alias() {
27 let json = r#"42"#;
28 let result: Result<i32> = from_str(json);
29 assert!(result.is_ok());
30 assert_eq!(result.unwrap(), 42);
31 }
32
33 #[test]
34 fn error_diagnostic_is_send_and_sync() {
35 fn assert_send_sync<T: Send + Sync>() {}
36
37 let json = r#"{}"#;
38 let result: Result<serde_json::Value> = from_str(json);
39 assert!(result.is_ok());
40
41 assert_send_sync::<ErrorDiagnostic>();
42 }
43
44 #[test]
45 fn error_diagnostic_display() {
46 let json = r#"invalid json"#;
47 let result: Result<serde_json::Value> = from_str(json);
48 assert!(result.is_err());
49
50 let error = result.unwrap_err();
51 let error_string = format!("{}", error);
52 assert!(!error_string.is_empty());
53 }
54}
55