mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-27 01:20:48 +00:00
Add raw string literal test cases
This commit is contained in:
parent
3b90e7d1ed
commit
f0a3490e97
@ -5,6 +5,7 @@
|
||||
)]
|
||||
|
||||
use proc_macro2::{Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree};
|
||||
use std::iter;
|
||||
use std::panic;
|
||||
use std::str::{self, FromStr};
|
||||
|
||||
@ -118,6 +119,25 @@ fn literal_string() {
|
||||
#[test]
|
||||
fn literal_raw_string() {
|
||||
"r\"\r\n\"".parse::<TokenStream>().unwrap();
|
||||
|
||||
fn raw_string_literal_with_hashes(n: usize) -> String {
|
||||
let mut literal = String::new();
|
||||
literal.push('r');
|
||||
literal.extend(iter::repeat('#').take(n));
|
||||
literal.push('"');
|
||||
literal.push('"');
|
||||
literal.extend(iter::repeat('#').take(n));
|
||||
literal
|
||||
}
|
||||
|
||||
raw_string_literal_with_hashes(255)
|
||||
.parse::<TokenStream>()
|
||||
.unwrap();
|
||||
|
||||
// https://github.com/rust-lang/rust/pull/95251
|
||||
raw_string_literal_with_hashes(256)
|
||||
.parse::<TokenStream>()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user