commit
2a1bac3d56
4 changed files with 26 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
language: rust
|
||||
rust:
|
||||
- 1.8.0
|
||||
- 1.9.0
|
||||
- 1.16.0
|
||||
- beta
|
||||
- nightly
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -263,7 +263,7 @@ fn need_quotes(string: &str) -> bool {
|
|||
|| need_quotes_spaces(string)
|
||||
|| string.contains(|character: char| {
|
||||
match character {
|
||||
':' | '{' | '}' | '[' | ']' | ',' | '&' | '*' | '#' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@' | '`' | '\\' | '\0' ... '\x06' | '\t' | '\n' | '\r' | '\x0e' ... '\x1a' | '\x1c' ... '\x1f' => true,
|
||||
':' | '{' | '}' | '[' | ']' | ',' | '&' | '*' | '#' | '?' | '|' | '-' | '<' | '>' | '=' | '!' | '%' | '@' | '`' | '\"' | '\'' | '\\' | '\0' ... '\x06' | '\t' | '\n' | '\r' | '\x0e' ... '\x1a' | '\x1c' ... '\x1f' => true,
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
|
|
21
saphyr/tests/quickcheck.rs
Normal file
21
saphyr/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