| 268 | |
| 269 | #[test] |
| 270 | fn monotonic_counter() { |
| 271 | // Bytes sent: monotonically increasing by ~1000 each step. |
| 272 | let values: Vec<i64> = (0..10_000).map(|i| i * 1000).collect(); |
| 273 | let encoded = encode(&values); |
| 274 | let decoded = decode(&encoded).unwrap(); |
| 275 | assert_eq!(decoded, values); |
| 276 | |
| 277 | // All deltas are exactly 1000 → zigzag(1000) = 2000 → 2 bytes each. |
| 278 | let bytes_per_sample = encoded.len() as f64 / values.len() as f64; |
| 279 | assert!( |
| 280 | bytes_per_sample < 3.0, |
| 281 | "monotonic counter should compress to <3 bytes/sample, got {bytes_per_sample:.2}" |
| 282 | ); |
| 283 | } |
| 284 | |
| 285 | #[test] |
| 286 | fn counter_with_small_increments() { |