MCPcopy Create free account
hub / github.com/evilsocket/cake / test_decode_roundtrip_16bit

Function test_decode_roundtrip_16bit

cake-core/src/utils/wav.rs:270–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 2

decode_wav_monoFunction · 0.85
encode_wav_bytesFunction · 0.70

Tested by

no test coverage detected