Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Added tests for preprocessor_stringify, fails for '
Browse files Browse the repository at this point in the history
  • Loading branch information
hdamron17 committed May 25, 2020
1 parent 3941074 commit b8bab0a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lex/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,4 +1644,17 @@ int main(){}
);
// TODO test for #includes
}
#[test]
fn preprocess_stringify() {
let assert_same_stringified = |cpp: &str, cpp_src: &str| {
assert_same_exact(
&format!("#define xstr(a) #a\nxstr({})", cpp),
&format!("\n{}", cpp_src));
};
assert_same_stringified("a + b", r#""a + b""#);
assert_same_stringified(r#"b +"c""#, r#""b +\"c\"""#);
assert_same_stringified(r#""+\\+\n+\"+""#, r#""\"+\\\\+\\n+\\\"+\"""#);
assert_same_stringified(r#""\'""#, r#""\"\\'\""#); // TODO figure out why ' is different
// TODO test unicode chars
}
}

0 comments on commit b8bab0a

Please sign in to comment.