Files
rust/tests/ui/parser/raw/raw-string-literals.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
998 B
Rust
Raw Normal View History

2025-07-01 18:24:12 +05:00
//! Tests various forms of raw string literals
//@ run-pass
2025-07-01 18:24:12 +05:00
// ignore-tidy-tab: Raw strings deliberately contain tabs
// ignore-tidy-linelength: Long pattern string for vim syntax test
2014-02-05 16:33:10 -06:00
pub fn main() {
assert_eq!(r"abc", "abc");
assert_eq!(r#"abc"#, "abc");
assert_eq!(r"###", "###");
assert_eq!(r"\", "\\");
assert_eq!(r#"\""#, "\\\"");
assert_eq!(r#"#"\n""#, "#\"\\n\"");
assert_eq!(r##"a"#"b"##, "a\"#\"b");
// from rust.vim
2025-07-01 18:24:12 +05:00
assert_eq!(
r#""%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\=.[^]]*\]\)""#,
"\"%\\(\\d\\+\\$\\)\\=[-+' #0*]*\\(\\d*\\|\\*\\|\\*\\d\\+\\$\\)\\(\\.\\(\\d*\\|\\*\\|\\*\\d\\+\\$\\)\\)\\=\\([hlLjzt]\\|ll\\|hh\\)\\=\\([aAbdiuoxXDOUfFeEgGcCsSpn?]\\|\\[\\^\\=.[^]]*\\]\\)\""
);
2025-07-01 18:24:12 +05:00
assert_eq!(
r"newline:'
', tab:' ', unicode:'', null:''",
2025-07-01 18:24:12 +05:00
"newline:'\n', tab:'\t', unicode:'\u{25cf}', null:'\0'"
);
}