Skip to content

Commit

Permalink
test WTF8 encoding corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 30, 2020
1 parent 508371a commit 5ed641e
Showing 1 changed file with 23 additions and 0 deletions.
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();
}

0 comments on commit 5ed641e

Please sign in to comment.