compiletest: unit test parse_normalization_string
There is a FIXME inside that function and I think the unit tests can be helpful to resolve it without breaking anything else.
This commit is contained in:
parent
818f6823ad
commit
9637c27fb5
1 changed files with 26 additions and 0 deletions
|
@ -873,3 +873,29 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> {
|
||||||
*line = &line[end + 1..];
|
*line = &line[end + 1..];
|
||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_normalization_string() {
|
||||||
|
let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)\".";
|
||||||
|
let first = parse_normalization_string(&mut s);
|
||||||
|
assert_eq!(first, Some("something (32 bits)".to_owned()));
|
||||||
|
assert_eq!(s, " -> \"something ($WORD bits)\".");
|
||||||
|
|
||||||
|
// Nothing to normalize (No quotes)
|
||||||
|
let mut s = "normalize-stderr-32bit: something (32 bits) -> something ($WORD bits).";
|
||||||
|
let first = parse_normalization_string(&mut s);
|
||||||
|
assert_eq!(first, None);
|
||||||
|
assert_eq!(s, r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."#);
|
||||||
|
|
||||||
|
// Nothing to normalize (Only a single quote)
|
||||||
|
let mut s = "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits).";
|
||||||
|
let first = parse_normalization_string(&mut s);
|
||||||
|
assert_eq!(first, None);
|
||||||
|
assert_eq!(s, "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits).");
|
||||||
|
|
||||||
|
// Nothing to normalize (Three quotes)
|
||||||
|
let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits).";
|
||||||
|
let first = parse_normalization_string(&mut s);
|
||||||
|
assert_eq!(first, Some("something (32 bits)".to_owned()));
|
||||||
|
assert_eq!(s, " -> \"something ($WORD bits).");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue