()
| 424 | |
| 425 | #[test] |
| 426 | fn wrapping_behavior() { |
| 427 | // Verify the ring buffer works correctly when counters wrap past capacity. |
| 428 | let (mut tx, mut rx) = RingBuffer::channel::<u64>(4); |
| 429 | |
| 430 | for round in 0..1000u64 { |
| 431 | for i in 0..4 { |
| 432 | tx.try_push(round * 4 + i).unwrap(); |
| 433 | } |
| 434 | for i in 0..4 { |
| 435 | assert_eq!(rx.try_pop().unwrap(), round * 4 + i); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | #[test] |
| 441 | fn metrics_counting() { |