Skip to content

Commit

Permalink
tests: Move test to bounded.rs
Browse files Browse the repository at this point in the history
Previously the force_push test was placed in unbounded.rs by accident

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Apr 14, 2024
1 parent 89a64f8 commit 576965a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
28 changes: 27 additions & 1 deletion tests/bounded.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
28 changes: 1 addition & 27 deletions tests/unbounded.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 576965a

Please sign in to comment.