()
| 171 | |
| 172 | #[test] |
| 173 | fn overflow_drops_oldest() { |
| 174 | let mut ring = TelemetryRing::new(4); |
| 175 | |
| 176 | // Write 6 samples into a capacity-4 ring. |
| 177 | for i in 0..6 { |
| 178 | ring.record(sample(i, i as u64)); |
| 179 | } |
| 180 | |
| 181 | assert!(ring.dropped_count() > 0); |
| 182 | |
| 183 | let mut buf = Vec::new(); |
| 184 | ring.drain_into(&mut buf); |
| 185 | |
| 186 | // Should have the most recent samples, not the oldest. |
| 187 | assert!(!buf.is_empty()); |
| 188 | let last = buf.last().unwrap(); |
| 189 | assert_eq!(last.metric_id, 5); |
| 190 | } |
| 191 | |
| 192 | #[test] |
| 193 | fn empty_drain_returns_zero() { |
nothing calls this directly
no test coverage detected