diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-09-26 12:52:37 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-10-02 20:40:36 +0200 |
commit | 7485f27059a6bccf4bbecf695c76fbda82da48d3 (patch) | |
tree | 3966b3a0b4b02b108460fa2e2d254a84b2e265c5 /tests/file_hjson.rs | |
parent | 052c9503c65ee66074d00e8885aa13e6831bf079 (diff) |
Remove support for hjson
The serde-hjson crate is not maintained anymore and this feature is
actually causing pain in packaging even.
Thus, remove it.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'tests/file_hjson.rs')
-rw-r--r-- | tests/file_hjson.rs | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/tests/file_hjson.rs b/tests/file_hjson.rs deleted file mode 100644 index 4ac2e12..0000000 --- a/tests/file_hjson.rs +++ /dev/null @@ -1,80 +0,0 @@ -#![cfg(feature = "hjson")] - -extern crate config; -extern crate float_cmp; -extern crate serde; - -#[macro_use] -extern crate serde_derive; - -use std::path::PathBuf; - -use config::*; -use float_cmp::ApproxEqUlps; - -#[derive(Debug, Deserialize)] -struct Place { - name: String, - longitude: f64, - latitude: f64, - favorite: bool, - telephone: Option<String>, - reviews: u64, - creator: Map<String, Value>, - rating: Option<f32>, -} - -#[derive(Debug, Deserialize)] -struct Settings { - debug: f64, - production: Option<String>, - place: Place, - #[serde(rename = "arr")] - elements: Vec<String>, -} - -fn make() -> Config { - Config::builder() - .add_source(File::new("tests/Settings", FileFormat::Hjson)) - .build() - .unwrap() -} - -#[test] -fn test_file() { - let c = make(); - - // Deserialize the entire file as single struct - let s: Settings = c.try_into().unwrap(); - - assert!(s.debug.approx_eq_ulps(&1.0, 2)); - assert_eq!(s.production, Some("false".to_string())); - assert_eq!(s.place.name, "Torre di Pisa"); - assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2)); - assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2)); - assert_eq!(s.place.favorite, false); - assert_eq!(s.place.reviews, 3866); - assert_eq!(s.place.rating, Some(4.5)); - assert_eq!(s.place.telephone, None); - assert_eq!(s.elements.len(), 10); - assert_eq!(s.elements[3], "4".to_string()); - assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() - ); -} - -#[test] -fn test_error_parse() { - let res = Config::builder() - .add_source(File::new("tests/Settings-invalid", FileFormat::Hjson)) - .build(); - - let path: PathBuf = ["tests", "Settings-invalid.hjson"].iter().collect(); - - assert!(res.is_err()); - assert_eq!( - res.unwrap_err().to_string(), - format!("Found a punctuator where a key name was expected (check your syntax or use quotes if the key name includes {{}}[],: or whitespace) at line 4 column 1 in {}", path.display()) - ); -} |