()
| 268 | |
| 269 | #[test] |
| 270 | fn test_decode_roundtrip_16bit() { |
| 271 | // Encode then decode — samples should survive the i16 roundtrip |
| 272 | let original = vec![0.0, 0.5, -0.5, 1.0, -1.0]; |
| 273 | let wav = encode_wav_bytes(&original, 24000); |
| 274 | let decoded = decode_wav_mono(&wav, 24000).unwrap(); |
| 275 | assert_eq!(decoded.len(), original.len()); |
| 276 | for (o, d) in original.iter().zip(decoded.iter()) { |
| 277 | // 16-bit quantization error: max ~1/32768 ≈ 3e-5 |
| 278 | assert!( |
| 279 | (o - d).abs() < 0.001, |
| 280 | "expected ~{}, got {}", |
| 281 | o, |
| 282 | d |
| 283 | ); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | #[test] |
| 288 | fn test_decode_invalid_header() { |
nothing calls this directly
no test coverage detected