Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6b95606
rustc_trans: do not generate allocas for unused locals.
eddyb Aug 23, 2016
892bf3d
Use a macro in test_decode_utf8 to preserve line numbers in panic mes…
SimonSapin Aug 23, 2016
46226a7
Yield Err in char::decode_utf8 per Unicode, like String::from_utf8_lossy
SimonSapin Aug 23, 2016
2655c89
Use idiomatic names for string-related methods names.
frewsxcv Aug 24, 2016
19aae8e
Reuse iterator to avoid unnecessary creation.
frewsxcv Aug 24, 2016
28ecfb6
Move ItemEnum → Generics logic into method on ItemEnum.
frewsxcv Aug 20, 2016
7dc4116
Migrate Context::maybe_ignore_item method to standalone function.
frewsxcv Aug 20, 2016
30397ae
Migrate ItemType::from_item to convert::From.
frewsxcv Aug 20, 2016
0c9ff54
Migrate ItemType::from_type_kind to convert::From.
frewsxcv Aug 20, 2016
9dde563
Stop reexporting `PrimitiveType` enum in librustdoc.
frewsxcv Aug 23, 2016
5c849f4
Remove unnecessary 'Primitive' prefix on `PrimitiveType` enum variants.
frewsxcv Aug 23, 2016
8a6f7a5
Implement `From<ast::IntTy>` for `PrimitiveType`.
frewsxcv Aug 23, 2016
168cfea
Implement `From<ast::UintTy>` for `PrimitiveType`.
frewsxcv Aug 23, 2016
42e8ac8
Implement `From<ast::FloatTy>` for `PrimitiveType`.
frewsxcv Aug 23, 2016
cf64611
Fix debug line info for macro expansions.
vadimcn Aug 25, 2016
e0e1954
Rollup merge of #35238 - vadimcn:macro-debug-locs, r=michaelwoerister
Manishearth Aug 25, 2016
5e69622
Rollup merge of #35867 - frewsxcv:rustdoc-cleanup, r=alexcrichton
Manishearth Aug 25, 2016
7963bbb
Rollup merge of #35916 - eddyb:mir-no-dead-allocas, r=Aatch
Manishearth Aug 25, 2016
5deee46
Rollup merge of #35947 - SimonSapin:decodeutf8-error-handling, r=alex…
Manishearth Aug 25, 2016
cf597ab
Rollup merge of #35955 - frewsxcv:idiomatic-methods, r=eddyb
Manishearth Aug 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use a macro in test_decode_utf8 to preserve line numbers in panic mes…
…sages.
  • Loading branch information
SimonSapin committed Aug 23, 2016
commit 892bf3d41d8f1b5c26f19fd0f20edd1584c958a1
50 changes: 26 additions & 24 deletions src/libcoretest/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,29 +358,31 @@ fn eu_iterator_specializations() {

#[test]
fn test_decode_utf8() {
use core::char::*;
use core::iter::FromIterator;

for &(str, bs) in [("", &[] as &[u8]),
("A", &[0x41u8] as &[u8]),
("�", &[0xC1u8, 0x81u8] as &[u8]),
("♥", &[0xE2u8, 0x99u8, 0xA5u8]),
("♥A", &[0xE2u8, 0x99u8, 0xA5u8, 0x41u8] as &[u8]),
("�", &[0xE2u8, 0x99u8] as &[u8]),
("�A", &[0xE2u8, 0x99u8, 0x41u8] as &[u8]),
("�", &[0xC0u8] as &[u8]),
("�A", &[0xC0u8, 0x41u8] as &[u8]),
("�", &[0x80u8] as &[u8]),
("�A", &[0x80u8, 0x41u8] as &[u8]),
("�", &[0xFEu8] as &[u8]),
("�A", &[0xFEu8, 0x41u8] as &[u8]),
("�", &[0xFFu8] as &[u8]),
("�A", &[0xFFu8, 0x41u8] as &[u8])].into_iter() {
assert!(Iterator::eq(str.chars(),
decode_utf8(bs.into_iter().map(|&b|b))
.map(|r_b| r_b.unwrap_or('\u{FFFD}'))),
"chars = {}, bytes = {:?}, decoded = {:?}", str, bs,
Vec::from_iter(decode_utf8(bs.into_iter().map(|&b|b))
.map(|r_b| r_b.unwrap_or('\u{FFFD}'))));
macro_rules! assert_decode_utf8 {
($input_bytes: expr, $expected_str: expr) => {
let input_bytes: &[u8] = &$input_bytes;
let s = char::decode_utf8(input_bytes.iter().cloned())
.map(|r_b| r_b.unwrap_or('\u{FFFD}'))
.collect::<String>();
assert_eq!(s, $expected_str,
"input bytes: {:?}, expected str: {:?}, result: {:?}",
input_bytes, $expected_str, s);
}
}

assert_decode_utf8!([], "");
assert_decode_utf8!([0x41], "A");
assert_decode_utf8!([0xC1, 0x81], "�");
assert_decode_utf8!([0xE2, 0x99, 0xA5], "♥");
assert_decode_utf8!([0xE2, 0x99, 0xA5, 0x41], "♥A");
assert_decode_utf8!([0xE2, 0x99], "�");
assert_decode_utf8!([0xE2, 0x99, 0x41], "�A");
assert_decode_utf8!([0xC0], "�");
assert_decode_utf8!([0xC0, 0x41], "�A");
assert_decode_utf8!([0x80], "�");
assert_decode_utf8!([0x80, 0x41], "�A");
assert_decode_utf8!([0xFE], "�");
assert_decode_utf8!([0xFE, 0x41], "�A");
assert_decode_utf8!([0xFF], "�");
assert_decode_utf8!([0xFF, 0x41], "�A");
}