summaryrefslogtreecommitdiff
path: root/vendor/rayon/tests/drain_vec.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/rayon/tests/drain_vec.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/rayon/tests/drain_vec.rs')
-rw-r--r--vendor/rayon/tests/drain_vec.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/vendor/rayon/tests/drain_vec.rs b/vendor/rayon/tests/drain_vec.rs
new file mode 100644
index 0000000..08f1120
--- /dev/null
+++ b/vendor/rayon/tests/drain_vec.rs
@@ -0,0 +1,41 @@
+use rayon::prelude::*;
+
+#[test]
+fn drain_vec_yielded() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(0..5).collect::<Vec<_>>();
+
+ assert_eq!(&yielded, &[0, 1, 2, 3, 4]);
+ assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_dropped() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(0..5);
+
+ drop(yielded);
+ assert_eq!(&vec_org, &[5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_empty_range_yielded() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(5..5).collect::<Vec<_>>();
+
+ assert_eq!(&yielded, &[]);
+ assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+}
+
+#[test]
+fn drain_vec_empty_range_dropped() {
+ let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+
+ let yielded = vec_org.par_drain(5..5);
+
+ drop(yielded);
+ assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+}