MCPcopy Create free account
hub / github.com/RustCrypto/formats / decode_test

Function decode_test

base64ct/src/decoder.rs:597–619  ·  view source on GitHub ↗

Core functionality of a decoding test

(expected: &[u8], f: F)

Source from the content-addressed store, hash-verified

595
596 /// Core functionality of a decoding test
597 fn decode_test<'a, F, V>(expected: &[u8], f: F)
598 where
599 F: Fn() -> Decoder<'a, V>,
600 V: Alphabet,
601 {
602 for chunk_size in 1..expected.len() {
603 let mut decoder = f();
604 let mut remaining_len = decoder.remaining_len();
605 let mut buffer = [0u8; 1024];
606
607 for chunk in expected.chunks(chunk_size) {
608 assert!(!decoder.is_finished());
609 let decoded = decoder.decode(&mut buffer[..chunk.len()]).unwrap();
610 assert_eq!(chunk, decoded);
611
612 remaining_len -= decoded.len();
613 assert_eq!(remaining_len, decoder.remaining_len());
614 }
615
616 assert!(decoder.is_finished());
617 assert_eq!(decoder.remaining_len(), 0);
618 }
619 }
620}

Callers 4

decode_paddedFunction · 0.85
decode_unpaddedFunction · 0.85
decode_multiline_paddedFunction · 0.85

Calls 3

lenMethod · 0.45
remaining_lenMethod · 0.45
decodeMethod · 0.45

Tested by 4

decode_paddedFunction · 0.68
decode_unpaddedFunction · 0.68
decode_multiline_paddedFunction · 0.68