about summary refs log tree commit diff
path: root/library/alloc/tests
diff options
context:
space:
mode:
Diffstat (limited to 'library/alloc/tests')
-rw-r--r--library/alloc/tests/slice.rs2
-rw-r--r--library/alloc/tests/str.rs165
-rw-r--r--library/alloc/tests/string.rs35
-rw-r--r--library/alloc/tests/vec.rs2
-rw-r--r--library/alloc/tests/vec_deque.rs4
-rw-r--r--library/alloc/tests/vec_deque_alloc_error.rs4
6 files changed, 96 insertions, 116 deletions
diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs
index df5a8af16fd..9625e3d2b5e 100644
--- a/library/alloc/tests/slice.rs
+++ b/library/alloc/tests/slice.rs
@@ -1417,8 +1417,8 @@ fn test_box_slice_clone() {
 #[cfg_attr(target_os = "emscripten", ignore)]
 #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
 fn test_box_slice_clone_panics() {
-    use std::sync::atomic::{AtomicUsize, Ordering};
     use std::sync::Arc;
+    use std::sync::atomic::{AtomicUsize, Ordering};
 
     struct Canary {
         count: Arc<AtomicUsize>,
diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs
index a6b1fe5b979..a80e5275dab 100644
--- a/library/alloc/tests/str.rs
+++ b/library/alloc/tests/str.rs
@@ -1524,14 +1524,18 @@ fn test_lines() {
     t("bare\r", &["bare\r"]);
     t("bare\rcr", &["bare\rcr"]);
     t("Text\n\r", &["Text", "\r"]);
-    t(
-        "\nMäry häd ä little lämb\n\r\nLittle lämb\n",
-        &["", "Märy häd ä little lämb", "", "Little lämb"],
-    );
-    t(
-        "\r\nMäry häd ä little lämb\n\nLittle lämb",
-        &["", "Märy häd ä little lämb", "", "Little lämb"],
-    );
+    t("\nMäry häd ä little lämb\n\r\nLittle lämb\n", &[
+        "",
+        "Märy häd ä little lämb",
+        "",
+        "Little lämb",
+    ]);
+    t("\r\nMäry häd ä little lämb\n\nLittle lämb", &[
+        "",
+        "Märy häd ä little lämb",
+        "",
+        "Little lämb",
+    ]);
 }
 
 #[test]
@@ -1971,88 +1975,73 @@ mod pattern {
         assert_eq!(v, right);
     }
 
-    make_test!(
-        str_searcher_ascii_haystack,
-        "bb",
-        "abbcbbd",
-        [Reject(0, 1), Match(1, 3), Reject(3, 4), Match(4, 6), Reject(6, 7),]
-    );
-    make_test!(
-        str_searcher_ascii_haystack_seq,
-        "bb",
-        "abbcbbbbd",
-        [Reject(0, 1), Match(1, 3), Reject(3, 4), Match(4, 6), Match(6, 8), Reject(8, 9),]
-    );
-    make_test!(
-        str_searcher_empty_needle_ascii_haystack,
-        "",
-        "abbcbbd",
-        [
-            Match(0, 0),
-            Reject(0, 1),
-            Match(1, 1),
-            Reject(1, 2),
-            Match(2, 2),
-            Reject(2, 3),
-            Match(3, 3),
-            Reject(3, 4),
-            Match(4, 4),
-            Reject(4, 5),
-            Match(5, 5),
-            Reject(5, 6),
-            Match(6, 6),
-            Reject(6, 7),
-            Match(7, 7),
-        ]
-    );
-    make_test!(
-        str_searcher_multibyte_haystack,
-        " ",
-        "├──",
-        [Reject(0, 3), Reject(3, 6), Reject(6, 9),]
-    );
-    make_test!(
-        str_searcher_empty_needle_multibyte_haystack,
-        "",
-        "├──",
-        [
-            Match(0, 0),
-            Reject(0, 3),
-            Match(3, 3),
-            Reject(3, 6),
-            Match(6, 6),
-            Reject(6, 9),
-            Match(9, 9),
-        ]
-    );
+    make_test!(str_searcher_ascii_haystack, "bb", "abbcbbd", [
+        Reject(0, 1),
+        Match(1, 3),
+        Reject(3, 4),
+        Match(4, 6),
+        Reject(6, 7),
+    ]);
+    make_test!(str_searcher_ascii_haystack_seq, "bb", "abbcbbbbd", [
+        Reject(0, 1),
+        Match(1, 3),
+        Reject(3, 4),
+        Match(4, 6),
+        Match(6, 8),
+        Reject(8, 9),
+    ]);
+    make_test!(str_searcher_empty_needle_ascii_haystack, "", "abbcbbd", [
+        Match(0, 0),
+        Reject(0, 1),
+        Match(1, 1),
+        Reject(1, 2),
+        Match(2, 2),
+        Reject(2, 3),
+        Match(3, 3),
+        Reject(3, 4),
+        Match(4, 4),
+        Reject(4, 5),
+        Match(5, 5),
+        Reject(5, 6),
+        Match(6, 6),
+        Reject(6, 7),
+        Match(7, 7),
+    ]);
+    make_test!(str_searcher_multibyte_haystack, " ", "├──", [
+        Reject(0, 3),
+        Reject(3, 6),
+        Reject(6, 9),
+    ]);
+    make_test!(str_searcher_empty_needle_multibyte_haystack, "", "├──", [
+        Match(0, 0),
+        Reject(0, 3),
+        Match(3, 3),
+        Reject(3, 6),
+        Match(6, 6),
+        Reject(6, 9),
+        Match(9, 9),
+    ]);
     make_test!(str_searcher_empty_needle_empty_haystack, "", "", [Match(0, 0),]);
     make_test!(str_searcher_nonempty_needle_empty_haystack, "├", "", []);
-    make_test!(
-        char_searcher_ascii_haystack,
-        'b',
-        "abbcbbd",
-        [
-            Reject(0, 1),
-            Match(1, 2),
-            Match(2, 3),
-            Reject(3, 4),
-            Match(4, 5),
-            Match(5, 6),
-            Reject(6, 7),
-        ]
-    );
-    make_test!(
-        char_searcher_multibyte_haystack,
-        ' ',
-        "├──",
-        [Reject(0, 3), Reject(3, 6), Reject(6, 9),]
-    );
-    make_test!(
-        char_searcher_short_haystack,
-        '\u{1F4A9}',
-        "* \t",
-        [Reject(0, 1), Reject(1, 2), Reject(2, 3),]
-    );
+    make_test!(char_searcher_ascii_haystack, 'b', "abbcbbd", [
+        Reject(0, 1),
+        Match(1, 2),
+        Match(2, 3),
+        Reject(3, 4),
+        Match(4, 5),
+        Match(5, 6),
+        Reject(6, 7),
+    ]);
+    make_test!(char_searcher_multibyte_haystack, ' ', "├──", [
+        Reject(0, 3),
+        Reject(3, 6),
+        Reject(6, 9),
+    ]);
+    make_test!(char_searcher_short_haystack, '\u{1F4A9}', "* \t", [
+        Reject(0, 1),
+        Reject(1, 2),
+        Reject(2, 3),
+    ]);
 
     // See #85462
     #[test]
diff --git a/library/alloc/tests/string.rs b/library/alloc/tests/string.rs
index d996c55f946..1c8bff1564d 100644
--- a/library/alloc/tests/string.rs
+++ b/library/alloc/tests/string.rs
@@ -154,28 +154,19 @@ fn test_fromutf8error_into_lossy() {
 #[test]
 fn test_from_utf16() {
     let pairs = [
-        (
-            String::from("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
-            vec![
-                0xd800, 0xdf45, 0xd800, 0xdf3f, 0xd800, 0xdf3b, 0xd800, 0xdf46, 0xd800, 0xdf39,
-                0xd800, 0xdf3b, 0xd800, 0xdf30, 0x000a,
-            ],
-        ),
-        (
-            String::from("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
-            vec![
-                0xd801, 0xdc12, 0xd801, 0xdc49, 0xd801, 0xdc2e, 0xd801, 0xdc40, 0xd801, 0xdc32,
-                0xd801, 0xdc4b, 0x0020, 0xd801, 0xdc0f, 0xd801, 0xdc32, 0xd801, 0xdc4d, 0x000a,
-            ],
-        ),
-        (
-            String::from("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
-            vec![
-                0xd800, 0xdf00, 0xd800, 0xdf16, 0xd800, 0xdf0b, 0xd800, 0xdf04, 0xd800, 0xdf11,
-                0xd800, 0xdf09, 0x00b7, 0xd800, 0xdf0c, 0xd800, 0xdf04, 0xd800, 0xdf15, 0xd800,
-                0xdf04, 0xd800, 0xdf0b, 0xd800, 0xdf09, 0xd800, 0xdf11, 0x000a,
-            ],
-        ),
+        (String::from("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"), vec![
+            0xd800, 0xdf45, 0xd800, 0xdf3f, 0xd800, 0xdf3b, 0xd800, 0xdf46, 0xd800, 0xdf39, 0xd800,
+            0xdf3b, 0xd800, 0xdf30, 0x000a,
+        ]),
+        (String::from("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"), vec![
+            0xd801, 0xdc12, 0xd801, 0xdc49, 0xd801, 0xdc2e, 0xd801, 0xdc40, 0xd801, 0xdc32, 0xd801,
+            0xdc4b, 0x0020, 0xd801, 0xdc0f, 0xd801, 0xdc32, 0xd801, 0xdc4d, 0x000a,
+        ]),
+        (String::from("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"), vec![
+            0xd800, 0xdf00, 0xd800, 0xdf16, 0xd800, 0xdf0b, 0xd800, 0xdf04, 0xd800, 0xdf11, 0xd800,
+            0xdf09, 0x00b7, 0xd800, 0xdf0c, 0xd800, 0xdf04, 0xd800, 0xdf15, 0xd800, 0xdf04, 0xd800,
+            0xdf0b, 0xd800, 0xdf09, 0xd800, 0xdf11, 0x000a,
+        ]),
         (
             String::from("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
             vec![
diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs
index cf2ca4f0d65..f508a3e4c22 100644
--- a/library/alloc/tests/vec.rs
+++ b/library/alloc/tests/vec.rs
@@ -14,7 +14,7 @@ use std::fmt::Debug;
 use std::iter::InPlaceIterable;
 use std::mem::{size_of, swap};
 use std::ops::Bound::*;
-use std::panic::{catch_unwind, AssertUnwindSafe};
+use std::panic::{AssertUnwindSafe, catch_unwind};
 use std::rc::Rc;
 use std::sync::atomic::{AtomicU32, Ordering};
 use std::vec::{Drain, IntoIter};
diff --git a/library/alloc/tests/vec_deque.rs b/library/alloc/tests/vec_deque.rs
index 0891d99fe66..4b8d3c735f7 100644
--- a/library/alloc/tests/vec_deque.rs
+++ b/library/alloc/tests/vec_deque.rs
@@ -3,12 +3,12 @@
 
 use core::num::NonZero;
 use std::assert_matches::assert_matches;
-use std::collections::vec_deque::Drain;
 use std::collections::TryReserveErrorKind::*;
 use std::collections::VecDeque;
+use std::collections::vec_deque::Drain;
 use std::fmt::Debug;
 use std::ops::Bound::*;
-use std::panic::{catch_unwind, AssertUnwindSafe};
+use std::panic::{AssertUnwindSafe, catch_unwind};
 
 use Taggy::*;
 use Taggypar::*;
diff --git a/library/alloc/tests/vec_deque_alloc_error.rs b/library/alloc/tests/vec_deque_alloc_error.rs
index c41d8266eb4..21a9118a05b 100644
--- a/library/alloc/tests/vec_deque_alloc_error.rs
+++ b/library/alloc/tests/vec_deque_alloc_error.rs
@@ -1,8 +1,8 @@
 #![feature(alloc_error_hook, allocator_api)]
 
-use std::alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System};
+use std::alloc::{AllocError, Allocator, Layout, System, set_alloc_error_hook};
 use std::collections::VecDeque;
-use std::panic::{catch_unwind, AssertUnwindSafe};
+use std::panic::{AssertUnwindSafe, catch_unwind};
 use std::ptr::NonNull;
 
 #[test]