about summary refs log tree commit diff
path: root/library/std/src/sys/windows/stdio/tests.rs
diff options
context:
space:
mode:
authorShane Murphy <shaneeverittmurphy@gmail.com>2023-05-31 17:22:44 -0700
committerShane Murphy <shaneeverittmurphy@gmail.com>2023-05-31 17:25:53 -0700
commit1293c1720574144ec13df2bbdcf26dab8e3b771f (patch)
tree0a76177c0ace8686894ee09cea401e8ad3ac70d2 /library/std/src/sys/windows/stdio/tests.rs
parent871b5952023139738f72eba235063575062bc2e9 (diff)
downloadrust-1293c1720574144ec13df2bbdcf26dab8e3b771f.tar.gz
rust-1293c1720574144ec13df2bbdcf26dab8e3b771f.zip
Fix bug in utf16_to_utf8 for zero length strings
This fixes the behavior of sending EOF by pressing Ctrl+Z => Enter in a
windows console.

Previously, that would trip the unpaired surrogate error, whereas now we
correctly detect EOF.
Diffstat (limited to 'library/std/src/sys/windows/stdio/tests.rs')
-rw-r--r--library/std/src/sys/windows/stdio/tests.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/stdio/tests.rs b/library/std/src/sys/windows/stdio/tests.rs
new file mode 100644
index 00000000000..1e53e0bee63
--- /dev/null
+++ b/library/std/src/sys/windows/stdio/tests.rs
@@ -0,0 +1,6 @@
+use super::utf16_to_utf8;
+
+#[test]
+fn zero_size_read() {
+    assert_eq!(utf16_to_utf8(&[], &mut []).unwrap(), 0);
+}