tests: Move test to bounded.rs
Previously the force_push test was placed in unbounded.rs by accident Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
parent
89a64f8c3b
commit
576965a8a5
|
@ -1,6 +1,6 @@
|
|||
#![allow(clippy::bool_assert_comparison)]
|
||||
|
||||
use concurrent_queue::{ConcurrentQueue, PopError, PushError};
|
||||
use concurrent_queue::{ConcurrentQueue, ForcePushError, PopError, PushError};
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
use easy_parallel::Parallel;
|
||||
|
@ -136,6 +136,32 @@ fn close() {
|
|||
assert_eq!(q.pop(), Err(PopError::Closed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_push() {
|
||||
let q = ConcurrentQueue::<i32>::bounded(5);
|
||||
|
||||
for i in 1..=5 {
|
||||
assert_eq!(q.force_push(i), Ok(None));
|
||||
}
|
||||
|
||||
assert!(!q.is_closed());
|
||||
for i in 6..=10 {
|
||||
assert_eq!(q.force_push(i), Ok(Some(i - 5)));
|
||||
}
|
||||
assert_eq!(q.pop(), Ok(6));
|
||||
assert_eq!(q.force_push(11), Ok(None));
|
||||
for i in 12..=15 {
|
||||
assert_eq!(q.force_push(i), Ok(Some(i - 5)));
|
||||
}
|
||||
|
||||
assert!(q.close());
|
||||
assert_eq!(q.force_push(40), Err(ForcePushError(40)));
|
||||
for i in 11..=15 {
|
||||
assert_eq!(q.pop(), Ok(i));
|
||||
}
|
||||
assert_eq!(q.pop(), Err(PopError::Closed));
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[test]
|
||||
fn spsc() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(clippy::bool_assert_comparison)]
|
||||
|
||||
use concurrent_queue::{ConcurrentQueue, ForcePushError, PopError, PushError};
|
||||
use concurrent_queue::{ConcurrentQueue, PopError, PushError};
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
use easy_parallel::Parallel;
|
||||
|
@ -74,32 +74,6 @@ fn close() {
|
|||
assert_eq!(q.pop(), Err(PopError::Closed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_push() {
|
||||
let q = ConcurrentQueue::<i32>::bounded(5);
|
||||
|
||||
for i in 1..=5 {
|
||||
assert_eq!(q.force_push(i), Ok(None));
|
||||
}
|
||||
|
||||
assert!(!q.is_closed());
|
||||
for i in 6..=10 {
|
||||
assert_eq!(q.force_push(i), Ok(Some(i - 5)));
|
||||
}
|
||||
assert_eq!(q.pop(), Ok(6));
|
||||
assert_eq!(q.force_push(11), Ok(None));
|
||||
for i in 12..=15 {
|
||||
assert_eq!(q.force_push(i), Ok(Some(i - 5)));
|
||||
}
|
||||
|
||||
assert!(q.close());
|
||||
assert_eq!(q.force_push(40), Err(ForcePushError(40)));
|
||||
for i in 11..=15 {
|
||||
assert_eq!(q.pop(), Ok(i));
|
||||
}
|
||||
assert_eq!(q.pop(), Err(PopError::Closed));
|
||||
}
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[test]
|
||||
fn spsc() {
|
||||
|
|
Loading…
Reference in New Issue