about summary refs log tree commit diff
path: root/src/libcollectionstest
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-03-06 22:06:30 +0100
committerSimon Sapin <simon.sapin@exyr.org>2017-03-14 10:02:55 +0100
commitb5f16a10e9406fc1c19294fee1c33e507a17458e (patch)
tree64a3688eb665f235e80fe2687c1087af93909693 /src/libcollectionstest
parent182044248ca2aa569844a25e73f90e5bc2fd05d3 (diff)
Replace Utf8Error::resume_from with Utf8Error::error_len
Their relationship is:

* `resume_from = error_len.map(|l| l + valid_up_to)`
* error_len is always one of None, Some(1), Some(2), or Some(3).

When I started using resume_from I almost always ended up subtracting
valid_up_to to obtain error_len.
Therefore the latter is what should be provided in the first place.
Diffstat (limited to 'src/libcollectionstest')
-rw-r--r--src/libcollectionstest/lib.rs2
-rw-r--r--src/libcollectionstest/str.rs30
2 files changed, 16 insertions, 16 deletions
diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs
index a7018daf098..98d0b1c8e15 100644
--- a/src/libcollectionstest/lib.rs
+++ b/src/libcollectionstest/lib.rs
@@ -28,7 +28,7 @@
 #![feature(test)]
 #![feature(unboxed_closures)]
 #![feature(unicode)]
-#![feature(utf8_error_resume_from)]
+#![feature(utf8_error_error_len)]
 
 extern crate collections;
 extern crate test;
diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs
index 5de74d68b9e..c9b7104fec4 100644
--- a/src/libcollectionstest/str.rs
+++ b/src/libcollectionstest/str.rs
@@ -543,31 +543,31 @@ fn from_utf8_mostly_ascii() {
 #[test]
 fn from_utf8_error() {
     macro_rules! test {
-        ($input: expr, $expected_valid_up_to: expr, $expected_resume_from: expr) => {
+        ($input: expr, $expected_valid_up_to: expr, $expected_error_len: expr) => {
             let error = from_utf8($input).unwrap_err();
             assert_eq!(error.valid_up_to(), $expected_valid_up_to);
-            assert_eq!(error.resume_from(), $expected_resume_from);
+            assert_eq!(error.error_len(), $expected_error_len);
         }
     }
-    test!(b"A\xC3\xA9 \xFF ", 4, Some(5));
-    test!(b"A\xC3\xA9 \x80 ", 4, Some(5));
-    test!(b"A\xC3\xA9 \xC1 ", 4, Some(5));
-    test!(b"A\xC3\xA9 \xC1", 4, Some(5));
+    test!(b"A\xC3\xA9 \xFF ", 4, Some(1));
+    test!(b"A\xC3\xA9 \x80 ", 4, Some(1));
+    test!(b"A\xC3\xA9 \xC1 ", 4, Some(1));
+    test!(b"A\xC3\xA9 \xC1", 4, Some(1));
     test!(b"A\xC3\xA9 \xC2", 4, None);
-    test!(b"A\xC3\xA9 \xC2 ", 4, Some(5));
-    test!(b"A\xC3\xA9 \xC2\xC0", 4, Some(5));
+    test!(b"A\xC3\xA9 \xC2 ", 4, Some(1));
+    test!(b"A\xC3\xA9 \xC2\xC0", 4, Some(1));
     test!(b"A\xC3\xA9 \xE0", 4, None);
-    test!(b"A\xC3\xA9 \xE0\x9F", 4, Some(5));
+    test!(b"A\xC3\xA9 \xE0\x9F", 4, Some(1));
     test!(b"A\xC3\xA9 \xE0\xA0", 4, None);
-    test!(b"A\xC3\xA9 \xE0\xA0\xC0", 4, Some(6));
-    test!(b"A\xC3\xA9 \xE0\xA0 ", 4, Some(6));
-    test!(b"A\xC3\xA9 \xED\xA0\x80 ", 4, Some(5));
+    test!(b"A\xC3\xA9 \xE0\xA0\xC0", 4, Some(2));
+    test!(b"A\xC3\xA9 \xE0\xA0 ", 4, Some(2));
+    test!(b"A\xC3\xA9 \xED\xA0\x80 ", 4, Some(1));
     test!(b"A\xC3\xA9 \xF1", 4, None);
     test!(b"A\xC3\xA9 \xF1\x80", 4, None);
     test!(b"A\xC3\xA9 \xF1\x80\x80", 4, None);
-    test!(b"A\xC3\xA9 \xF1 ", 4, Some(5));
-    test!(b"A\xC3\xA9 \xF1\x80 ", 4, Some(6));
-    test!(b"A\xC3\xA9 \xF1\x80\x80 ", 4, Some(7));
+    test!(b"A\xC3\xA9 \xF1 ", 4, Some(1));
+    test!(b"A\xC3\xA9 \xF1\x80 ", 4, Some(2));
+    test!(b"A\xC3\xA9 \xF1\x80\x80 ", 4, Some(3));
 }
 
 #[test]