about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/tests/char.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/core/tests/char.rs b/library/core/tests/char.rs
index 2b857a65919..d776a08323c 100644
--- a/library/core/tests/char.rs
+++ b/library/core/tests/char.rs
@@ -309,6 +309,31 @@ fn test_decode_utf16() {
 }
 
 #[test]
+fn test_decode_utf16_size_hint() {
+    fn check(s: &[u16]) {
+        let mut iter = char::decode_utf16(s.iter().cloned());
+
+        loop {
+            let count = iter.clone().count();
+            let (lower, upper) = iter.size_hint();
+
+            assert!(
+                lower <= count && count <= upper.unwrap(),
+                "lower = {lower}, upper = {upper:?}"
+            );
+
+            if let None = iter.next() {
+                break;
+            }
+        }
+    }
+
+    check(&[0xD800, 0x41, 0x42]);
+    check(&[0xD800, 0]);
+    check(&[0xD834, 0x006d]);
+}
+
+#[test]
 fn ed_iterator_specializations() {
     // Check counting
     assert_eq!('\n'.escape_default().count(), 2);