Add quickcheck to find broken exports
This commit is contained in:
parent
8755753ed7
commit
61a36bfbf6
2 changed files with 24 additions and 0 deletions
|
@ -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"
|
||||
|
|
21
parser/tests/quickcheck.rs
Normal file
21
parser/tests/quickcheck.rs
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue