Add quickcheck to find broken exports

This commit is contained in:
Tom Parker 2017-03-12 16:02:18 +00:00 committed by Tom Parker
parent 15ce32bee8
commit 84ffcafbc2
2 changed files with 24 additions and 0 deletions

View file

@ -11,3 +11,6 @@ repository = "https://github.com/chyh1990/yaml-rust"
[dependencies]
clippy = { version = "^0.*", optional = true }
linked-hash-map = ">=0.0.9, <0.4"
[dev-dependencies]
quickcheck = "0.4"

View file

@ -0,0 +1,21 @@
extern crate yaml_rust;
#[macro_use]
extern crate quickcheck;
use quickcheck::TestResult;
use yaml_rust::{Yaml, YamlLoader, YamlEmitter};
use std::error::Error;
quickcheck! {
fn test_check_weird_keys(xs: Vec<String>) -> TestResult {
let mut out_str = String::new();
{
let mut emitter = YamlEmitter::new(&mut out_str);
emitter.dump(&Yaml::Array(xs.into_iter().map(|s| Yaml::String(s)).collect())).unwrap();
}
if let Err(err) = YamlLoader::load_from_str(&out_str) {
return TestResult::error(err.description());
}
return TestResult::passed();
}
}