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
@ -873,3 +873,29 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> {
|
||||
*line = &line[end + 1..];
|
||||
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 New Issue
Block a user