about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2018-12-15 10:58:24 +0100
committerPhilipp Hansch <dev@phansch.net>2018-12-15 11:00:26 +0100
commit9637c27fb531dc4a030bc978ebff4335baebc28d (patch)
tree551bcb2445211b34466e4c0ac8d37158952d22de /src/tools/compiletest
parent818f6823ad6f4faa09dd859ea83942e93e470860 (diff)
downloadrust-9637c27fb531dc4a030bc978ebff4335baebc28d.tar.gz
rust-9637c27fb531dc4a030bc978ebff4335baebc28d.zip
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.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/header.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 00383998242..8b3023e63df 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -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).");
+}