Skip to content

test WTF8 encoding corner cases #1440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b6fa392238a459c29a47e2cf824d79a49a8ba039
5fd2f06e99a985dd896684cb2c9f8c7090eca1ab
23 changes: 23 additions & 0 deletions tests/run-pass/wtf8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ignore-linux: tests Windows-only APIs
// ignore-macos: tests Windows-only APIs

use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::ffi::{OsStr, OsString};

fn test1() {
let base = "a\té \u{7f}💩\r";
let mut base: Vec<u16> = OsStr::new(base).encode_wide().collect();
base.push(0xD800);
let _res = OsString::from_wide(&base);
}

fn test2() {
let mut base: Vec<u16> = OsStr::new("aé ").encode_wide().collect();
base.push(0xD83D);
let mut _res: Vec<u16> = OsString::from_wide(&base).encode_wide().collect();
}

fn main() {
test1();
test2();
}