citum_engine/
reference.rs1pub use citum_schema::citation::{Citation, CitationItem, CitationMode, LocatorType};
16
17pub use citum_schema::reference::{
19 Contributor, ContributorList, EdtfString, FlatName, InputReference as Reference,
20 MultilingualString, NumOrStr, SimpleName, StructuredName, Title,
21};
22
23pub type Bibliography = indexmap::IndexMap<String, Reference>;
25
26#[cfg(test)]
27#[allow(
28 clippy::unwrap_used,
29 clippy::expect_used,
30 clippy::panic,
31 clippy::indexing_slicing,
32 clippy::todo,
33 clippy::unimplemented,
34 clippy::unreachable,
35 clippy::get_unwrap,
36 reason = "Panicking is acceptable and often desired in tests."
37)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn test_parse_csl_json() {
43 let json = r#"{
44 "id": "kuhn1962",
45 "type": "book",
46 "author": [{"family": "Kuhn", "given": "Thomas S."}],
47 "title": "The Structure of Scientific Revolutions",
48 "issued": {"date-parts": [[1962]]},
49 "publisher": "University of Chicago Press",
50 "publisher-place": "Chicago"
51 }"#;
52
53 let legacy: csl_legacy::csl_json::Reference = serde_json::from_str(json).unwrap();
54 let reference: Reference = legacy.into();
55 assert_eq!(reference.id().unwrap(), "kuhn1962");
56 assert_eq!(reference.ref_type(), "book");
57 if let Some(Contributor::ContributorList(list)) = reference.author()
59 && let Contributor::StructuredName(name) = &list.0[0]
60 {
61 assert_eq!(name.family, MultilingualString::Simple("Kuhn".to_string()));
62 }
63 }
64}