use spefparse::*; #[test] fn test_simple() { // read a simple spef, dump it, and compare with golden. let spef = SPEF::parse_str(include_str!("simple.spef")); let spef = match spef { Ok(spef) => spef, Err(e) => panic!("Parsing error: {e}") }; let redump = format!("{}", spef); assert_eq!(redump, include_str!("simple.dump.spef"), "bad re-dump. please compare output with simple.dump.spef."); // read the dumpped one, and check that it can be reconstructed. let spef_redump = SPEF::parse_str(include_str!("simple.dump.spef")) .unwrap(); assert_eq!(format!("{}", spef_redump), redump, "bad re-dump. please compare output with simple.dump.spef."); } #[test] fn test_simple_multithread() { // read the spef as streamed file with multi-threading, and // ensure it is the same. for thread_num in [1, 2, 4] { let spef = SPEF::try_parse_file( concat!(env!("CARGO_MANIFEST_DIR"), "/tests/simple.spef"), Some(thread_num) ); let spef = match spef { Ok(spef) => spef, Err(e) => panic!("Parsing error for file-based parser (thread: {thread_num}): {e}") }; let redump = format!("{}", spef); assert_eq!(redump, include_str!("simple.dump.spef"), "bad re-dump for file-based parser (thread: {}). please compare output with simple.dump.spef.", thread_num); } }