diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-17 08:34:59 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-17 11:50:28 -0800 |
| commit | 31e21613eefcf30e6b7a10954bbbfc873d30ad88 (patch) | |
| tree | 278a0c4470b74bbe96d5827ac08a629a3fde3bdd /src/libcoretest | |
| parent | 3315a3bf4273601f10ac9ec3759370e599703223 (diff) | |
| parent | df5404cfa837907405427e3aa4adf1d969e208c9 (diff) | |
| download | rust-31e21613eefcf30e6b7a10954bbbfc873d30ad88.tar.gz rust-31e21613eefcf30e6b7a10954bbbfc873d30ad88.zip | |
rollup merge of #19885: alexcrichton/char-escape
This changes the `escape_unicode` method on a `char` to use the new style of unicode escapes in the language. Closes #19811 Closes #19879
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/char.rs | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/src/libcoretest/char.rs b/src/libcoretest/char.rs index e5561bebb22..bed38f8c296 100644 --- a/src/libcoretest/char.rs +++ b/src/libcoretest/char.rs @@ -135,38 +135,35 @@ fn test_escape_default() { let s = string('~'); assert_eq!(s, "~"); let s = string('\x00'); - assert_eq!(s, "\\x00"); + assert_eq!(s, "\\u{0}"); let s = string('\x1f'); - assert_eq!(s, "\\x1f"); + assert_eq!(s, "\\u{1f}"); let s = string('\x7f'); - assert_eq!(s, "\\x7f"); - let s = string('\u00ff'); - assert_eq!(s, "\\u00ff"); - let s = string('\u011b'); - assert_eq!(s, "\\u011b"); - let s = string('\U0001d4b6'); - assert_eq!(s, "\\U0001d4b6"); + assert_eq!(s, "\\u{7f}"); + let s = string('\u{ff}'); + assert_eq!(s, "\\u{ff}"); + let s = string('\u{11b}'); + assert_eq!(s, "\\u{11b}"); + let s = string('\u{1d4b6}'); + assert_eq!(s, "\\u{1d4b6}"); } #[test] fn test_escape_unicode() { - fn string(c: char) -> String { - let mut result = String::new(); - escape_unicode(c, |c| { result.push(c); }); - return result; - } + fn string(c: char) -> String { c.escape_unicode().collect() } + let s = string('\x00'); - assert_eq!(s, "\\x00"); + assert_eq!(s, "\\u{0}"); let s = string('\n'); - assert_eq!(s, "\\x0a"); + assert_eq!(s, "\\u{a}"); let s = string(' '); - assert_eq!(s, "\\x20"); + assert_eq!(s, "\\u{20}"); let s = string('a'); - assert_eq!(s, "\\x61"); - let s = string('\u011b'); - assert_eq!(s, "\\u011b"); - let s = string('\U0001d4b6'); - assert_eq!(s, "\\U0001d4b6"); + assert_eq!(s, "\\u{61}"); + let s = string('\u{11b}'); + assert_eq!(s, "\\u{11b}"); + let s = string('\u{1d4b6}'); + assert_eq!(s, "\\u{1d4b6}"); } #[test] |
