#[cfg(test)] use vedirect_rs::nom_parse::parse_block; use vedirect_rs::extract_blocks; const SINGLE_BLOCK: &'static str = "DQpQSUQJMHhBMDU1DQpGVwkxNjQNClNFUiMJSFEyMjMyR1c0M0UNClYJMTMyMzANCkkJLTg3MA0KVlBWCTE0MjANClBQVgkwDQpDUwkwDQpNUFBUCTANCk9SCTB4MDAwMDAwMDENCkVSUgkwDQpMT0FECU9ODQpJTAk4MDANCkgxOQkxNDEwDQpIMjAJMzENCkgyMQk5NQ0KSDIyCTI5DQpIMjMJOTINCkhTRFMJNDcNCkNoZWNrc3VtCUA="; const STREAM_TEST_DATA: &'static str = "AD8NClBJRAkweEEwNTUNCkZXCTE2NA0KU0VSIwlIUTIyMzJHVzQzRQ0KVgkxMzIzMA0KSQktODcwDQpWUFYJMTQyMA0KUFBWCTANCkNTCTANCk1QUFQJMA0KT1IJMHgwMDAwMDAwMQ0KRVJSCTANCkxPQUQJT04NCklMCTgwMA0KSDE5CTE0MTANCkgyMAkzMQ0KSDIxCTk1DQpIMjIJMjkNCkgyMwk5Mg0KSFNEUwk0Nw0KQ2hlY2tzdW0JQA0KUElECTB4QTA1NQ0KRlcJMTY0DQpTRVIjCUhRMjIzMkdXNDNFDQpWCTEzMjMwDQpJCS04NzANClZQVgkxNDIwDQpQUFYJMA0KQ1MJMA0KTVBQVAkwDQpPUgkweDAwMDAwMDAxDQpFUlIJMA0KTE9BRAlPTg0KSUwJOTAwDQpIMTkJMTQxMA0KSDIwCTMxDQpIMjEJOTUNCkgyMgkyOQ0KSDIzCTkyDQpIU0RTCTQ3DQpDaGVja3N1bQk/DQpQSUQJMHhBMDU1DQpGVwkxNjQNClNFUiMJSFEyMjMyR1c0M0UNClYJMTMyMzANCkkJLTg4MA0KVlBWCTE0MjANClBQVgkwDQpDUwkwDQpNUFBUCTANCk9SCTB4MDAwMDAwMDENCkVSUgkwDQpMT0FECU9ODQpJTAk4MDANCkgxOQkxNDEwDQpIMjAJMzENCkgyMQk5NQ0KSDIyC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c0M0UNClYJMTMyMzANCkkJLTg3MA0KVlBWCTEzOTANClBQVgkwDQpDUwkwDQpNUFBUCTANCk9SCTB4MDAwMDAwMDENCkVSUgkwDQpMT0FECU9ODQpJTAk4MDANCkgxOQkxNDEwDQpIMjAJMzENCkgyMQk5NQ0KSDIyCTI5DQpIMjMJOTINCkhTRFMJNDcNCkNoZWNrc3VtCTo="; #[test] fn test_parse_single_block() { let bytes = simple_base64::decode(SINGLE_BLOCK).unwrap(); let (_, blocks) = parse_block(&bytes).unwrap(); assert_eq!(blocks.len(),1); for block in blocks { println!("Total: {}", block.kvs.len()); for (k, v) in block.kvs { println!( "{}: {}", String::from_utf8_lossy(&k), String::from_utf8_lossy(&v) ) } } } #[test] fn test_lib_block_grabber_stream() { let bytes = simple_base64::decode(STREAM_TEST_DATA).unwrap(); match extract_blocks(&bytes) { Ok(b) => { assert_eq!(b.len(),12); } Err(e) => { match e { _ => {println!("{e:#?}")} } } } } #[test] fn test_lib_block_grabber_single_block() { let bytes = simple_base64::decode(SINGLE_BLOCK).unwrap(); match extract_blocks(&bytes) { Ok(b) => { assert_eq!(b.len(), 1); } Err(e) => { match e { _ => {println!("{e:#?}")} } } } }