Skip to content

Commit 9637c27

Browse files
committed
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.
1 parent 818f682 commit 9637c27

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/tools/compiletest/src/header.rs

+26
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,29 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> {
873873
*line = &line[end + 1..];
874874
Some(result)
875875
}
876+
877+
#[test]
878+
fn test_parse_normalization_string() {
879+
let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)\".";
880+
let first = parse_normalization_string(&mut s);
881+
assert_eq!(first, Some("something (32 bits)".to_owned()));
882+
assert_eq!(s, " -> \"something ($WORD bits)\".");
883+
884+
// Nothing to normalize (No quotes)
885+
let mut s = "normalize-stderr-32bit: something (32 bits) -> something ($WORD bits).";
886+
let first = parse_normalization_string(&mut s);
887+
assert_eq!(first, None);
888+
assert_eq!(s, r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."#);
889+
890+
// Nothing to normalize (Only a single quote)
891+
let mut s = "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits).";
892+
let first = parse_normalization_string(&mut s);
893+
assert_eq!(first, None);
894+
assert_eq!(s, "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits).");
895+
896+
// Nothing to normalize (Three quotes)
897+
let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits).";
898+
let first = parse_normalization_string(&mut s);
899+
assert_eq!(first, Some("something (32 bits)".to_owned()));
900+
assert_eq!(s, " -> \"something ($WORD bits).");
901+
}

0 commit comments

Comments
 (0)