aboutsummaryrefslogtreecommitdiff
path: root/vendor/flume/tests/iter.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/flume/tests/iter.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/flume/tests/iter.rs')
-rw-r--r--vendor/flume/tests/iter.rs112
1 files changed, 0 insertions, 112 deletions
diff --git a/vendor/flume/tests/iter.rs b/vendor/flume/tests/iter.rs
deleted file mode 100644
index 4d69adb..0000000
--- a/vendor/flume/tests/iter.rs
+++ /dev/null
@@ -1,112 +0,0 @@
-//! Tests for iteration over receivers.
-
-extern crate crossbeam_utils;
-
-use flume::unbounded;
-use crossbeam_utils::thread::scope;
-
-#[test]
-fn nested_recv_iter() {
- let (s, r) = unbounded::<i32>();
- let (total_s, total_r) = unbounded::<i32>();
-
- scope(|scope| {
- scope.spawn(move |_| {
- let mut acc = 0;
- for x in r.iter() {
- acc += x;
- }
- total_s.send(acc).unwrap();
- });
-
- s.send(3).unwrap();
- s.send(1).unwrap();
- s.send(2).unwrap();
- drop(s);
- assert_eq!(total_r.recv().unwrap(), 6);
- })
- .unwrap();
-}
-
-#[test]
-fn recv_iter_break() {
- let (s, r) = unbounded::<i32>();
- let (count_s, count_r) = unbounded();
-
- scope(|scope| {
- scope.spawn(move |_| {
- let mut count = 0;
- for x in r.iter() {
- if count >= 3 {
- break;
- } else {
- count += x;
- }
- }
- count_s.send(count).unwrap();
- });
-
- s.send(2).unwrap();
- s.send(2).unwrap();
- s.send(2).unwrap();
- let _ = s.send(2);
- drop(s);
- assert_eq!(count_r.recv().unwrap(), 4);
- })
- .unwrap();
-}
-
-#[test]
-fn recv_try_iter() {
- let (request_s, request_r) = unbounded();
- let (response_s, response_r) = unbounded();
-
- scope(|scope| {
- scope.spawn(move |_| {
- let mut count = 0;
- loop {
- for x in response_r.try_iter() {
- count += x;
- if count == 6 {
- return;
- }
- }
- request_s.send(()).unwrap();
- }
- });
-
- for _ in request_r.iter() {
- if response_s.send(2).is_err() {
- break;
- }
- }
- })
- .unwrap();
-}
-
-#[test]
-fn recv_into_iter_owned() {
- let mut iter = {
- let (s, r) = unbounded::<i32>();
- s.send(1).unwrap();
- s.send(2).unwrap();
- r.into_iter()
- };
-
- assert_eq!(iter.next().unwrap(), 1);
- assert_eq!(iter.next().unwrap(), 2);
- assert_eq!(iter.next().is_none(), true);
-}
-
-#[test]
-fn recv_into_iter_borrowed() {
- let (s, r) = unbounded::<i32>();
- s.send(1).unwrap();
- s.send(2).unwrap();
- drop(s);
-
- let mut iter = (&r).into_iter();
- assert_eq!(iter.next().unwrap(), 1);
- assert_eq!(iter.next().unwrap(), 2);
- assert_eq!(iter.next().is_none(), true);
-}