]> git.lizzy.rs Git - rust.git/commitdiff
test WTF8 encoding corner cases
authorRalf Jung <post@ralfj.de>
Sat, 30 May 2020 16:46:26 +0000 (18:46 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 31 May 2020 23:12:31 +0000 (01:12 +0200)
tests/run-pass/wtf8.rs [new file with mode: 0644]

diff --git a/tests/run-pass/wtf8.rs b/tests/run-pass/wtf8.rs
new file mode 100644 (file)
index 0000000..2b4da78
--- /dev/null
@@ -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();
+}