Commit Graph

10 Commits

Author SHA1 Message Date
John Nunley 05e7bff8e5
tests: Add more tests for force_push
This commit adds more tests for the force_push functionality. These
tests are copied from the corresponding crossbeam implementation.

We also add a clone of the "spsc" test that uses force_push.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-22 19:01:51 -07:00
John Nunley 576965a8a5 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>
2024-04-13 23:40:59 -07:00
John Nunley c407467c20
feat: Add an overflow push method
In some cases it is desired to have a "lossy" queue for data. Such as an
event queue where more recent events should be prioritized over older
ones, where infinite storage is impractical. This commit adds a method
called "force_push" which enables this usage.

Bounded queue code is partially derived from the following commit:
bd75c3c45e

cc smol-rs/async-channel#44
2024-03-30 16:38:05 -07:00
John Nunley 71302ab09c
tests: Add WASM testing
This commit ensures this crate builds and works on WASM.

Signed-off-by: John Nunley <dev@notgull.net>
2023-12-16 11:20:15 -08:00
John Nunley 8c42b8dd9d
Add alternate implementations of synchronization primitives (#27) 2022-10-07 06:48:10 -07:00
Taiki Endo 434e8e9b2d Run more tests with Miri 2022-07-22 00:32:17 +09:00
Taiki Endo 8497007235 Ignore clippy::bool_assert_comparison lint in tests
```
warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:37:5
   |
37 |     assert_eq!(q.is_empty(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = note: `#[warn(clippy::bool_assert_comparison)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:38:5
   |
38 |     assert_eq!(q.is_full(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:43:5
   |
43 |     assert_eq!(q.is_empty(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:44:5
   |
44 |     assert_eq!(q.is_full(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:49:5
   |
49 |     assert_eq!(q.is_empty(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:50:5
   |
50 |     assert_eq!(q.is_full(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:55:5
   |
55 |     assert_eq!(q.is_empty(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/bounded.rs:56:5
   |
56 |     assert_eq!(q.is_full(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/unbounded.rs:22:5
   |
22 |     assert_eq!(q.is_empty(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = note: `#[warn(clippy::bool_assert_comparison)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/unbounded.rs:27:5
   |
27 |     assert_eq!(q.is_empty(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/unbounded.rs:32:5
   |
32 |     assert_eq!(q.is_empty(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:29:5
   |
29 |     assert_eq!(q.is_empty(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = note: `#[warn(clippy::bool_assert_comparison)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:30:5
   |
30 |     assert_eq!(q.is_full(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:35:5
   |
35 |     assert_eq!(q.is_empty(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:36:5
   |
36 |     assert_eq!(q.is_full(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:41:5
   |
41 |     assert_eq!(q.is_empty(), true);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison

warning: used `assert_eq!` with a literal bool
  --> tests/single.rs:42:5
   |
42 |     assert_eq!(q.is_full(), false);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
```
2022-07-17 22:34:00 +09:00
Taiki Endo b6f39c7aa8 Run Miri on CI 2022-01-08 18:09:30 +09:00
Stjepan Glavina ee83323156 Add special bounded(1) implementation 2020-08-05 18:57:58 +02:00
Stjepan Glavina 463ae0ea93 Initial commit 2020-05-27 21:31:05 +02:00