diff options
| author | David Tolnay <dtolnay@gmail.com> | 2022-03-26 12:53:49 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2022-03-26 12:58:39 -0700 |
| commit | f1fa84ce95db0cf9d06f2aa8b70764e7394291b1 (patch) | |
| tree | 0edb264b1c419100aa95acea75813ef6a44b83df | |
| parent | 1fca19c8ca4ae5e71e8b17a82c3acfeb78c48891 (diff) | |
| download | rust-f1fa84ce95db0cf9d06f2aa8b70764e7394291b1.tar.gz rust-f1fa84ce95db0cf9d06f2aa8b70764e7394291b1.zip | |
Add test for proc_macro Literal string and character constructors
| -rw-r--r-- | src/test/ui/proc-macro/auxiliary/api/parse.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/auxiliary/api/parse.rs b/src/test/ui/proc-macro/auxiliary/api/parse.rs index 6186b941ef6..e6b6be132a9 100644 --- a/src/test/ui/proc-macro/auxiliary/api/parse.rs +++ b/src/test/ui/proc-macro/auxiliary/api/parse.rs @@ -18,6 +18,17 @@ fn test_display_literal() { Literal::f64_unsuffixed(1e100).to_string(), "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0", ); + + assert_eq!( + Literal::string("a \t ❤ ' \" \u{1}").to_string(), + "\"a \\t ❤ \\' \\\" \\u{1}\"", + ); + assert_eq!(Literal::character('a').to_string(), "'\\u{61}'"); + assert_eq!(Literal::character('\t').to_string(), "'\\u{9}'"); + assert_eq!(Literal::character('❤').to_string(), "'\\u{2764}'"); + assert_eq!(Literal::character('\'').to_string(), "'\\u{27}'"); + assert_eq!(Literal::character('"').to_string(), "'\\u{22}'"); + assert_eq!(Literal::character('\u{1}').to_string(), "'\\u{1}'"); } fn test_parse_literal() { |
