diff options
Diffstat (limited to 'src/libcollectionstest')
| -rw-r--r-- | src/libcollectionstest/str.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs index 4d84855ddf9..0fde70aacdc 100644 --- a/src/libcollectionstest/str.rs +++ b/src/libcollectionstest/str.rs @@ -480,6 +480,18 @@ fn test_is_utf8() { } #[test] +fn from_utf8_mostly_ascii() { + // deny invalid bytes embedded in long stretches of ascii + for i in 32..64 { + let mut data = [0; 128]; + data[i] = 0xC0; + assert!(from_utf8(&data).is_err()); + data[i] = 0xC2; + assert!(from_utf8(&data).is_err()); + } +} + +#[test] fn test_is_utf16() { use rustc_unicode::str::is_utf16; |
