diff --git a/a2lfile/src/a2ml.rs b/a2lfile/src/a2ml.rs index 7407ad1..05d400f 100644 --- a/a2lfile/src/a2ml.rs +++ b/a2lfile/src/a2ml.rs @@ -1512,8 +1512,7 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = crate::load_from_string(A2L_TEXT, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(A2L_TEXT, None, true).unwrap(); assert!(a2l_file.project.module[0].if_data[0].ifdata_valid); let if_data = &a2l_file.project.module[0].if_data[0]; diff --git a/a2lfile/src/checker.rs b/a2lfile/src/checker.rs index 329387f..17b9e0a 100644 --- a/a2lfile/src/checker.rs +++ b/a2lfile/src/checker.rs @@ -1129,8 +1129,7 @@ mod test { FNC_VALUES 0 FLOAT32_IEEE ROW_DIR DIRECT /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid input quantity, conversion, axis points ref, and curve axis ref @@ -1146,8 +1145,7 @@ mod test { FNC_VALUES 0 FLOAT32_IEEE ROW_DIR DIRECT /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); @@ -1168,8 +1166,7 @@ mod test { /begin MEASUREMENT meas "" FLOAT32_IEEE cm 1 1.0 0 100 /end MEASUREMENT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT3, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT3, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // for msg in &log_msgs { // println!("{msg}"); @@ -1190,8 +1187,7 @@ mod test { /begin MEASUREMENT meas "" FLOAT32_IEEE cm 1 1.0 0 100 /end MEASUREMENT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT4, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT4, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid input quantity @@ -1204,8 +1200,7 @@ mod test { /begin TYPEDEF_AXIS typedef_axis_name "" input_quantity record_layout 0 conversion 1 0 100 /end TYPEDEF_AXIS /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid input quantity, record layout and conversion @@ -1220,8 +1215,7 @@ mod test { /begin RECORD_LAYOUT rl /end RECORD_LAYOUT /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); @@ -1233,8 +1227,7 @@ mod test { /begin AXIS_PTS axis_pts_name "" 0x1234 input_qty record_layout 0 conversion 3 0.0 10.0 /end AXIS_PTS /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid input quantity, record layout (aka deposit_record), and conversion @@ -1247,8 +1240,7 @@ mod test { /begin RECORD_LAYOUT rl /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); @@ -1263,8 +1255,7 @@ mod test { /end RECORD_LAYOUT /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT3, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT3, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1291,8 +1282,7 @@ mod test { /end VIRTUAL_CHARACTERISTIC /end CHARACTERISTIC /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 8); @@ -1303,8 +1293,7 @@ mod test { /begin RECORD_LAYOUT rl /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); @@ -1321,8 +1310,7 @@ mod test { AXIS_PTS_X 1 FLOAT32_IEEE INDEX_INCR DIRECT /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT3, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT3, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid axis descr for c, no axis descr for c2 assert_eq!(log_msgs.len(), 2); @@ -1336,8 +1324,7 @@ mod test { /end RECORD_LAYOUT /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT4, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT4, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1351,8 +1338,7 @@ mod test { /end AXIS_DESCR /end TYPEDEF_CHARACTERISTIC /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 4); @@ -1365,8 +1351,7 @@ mod test { /end RECORD_LAYOUT /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid axis descr assert_eq!(log_msgs.len(), 1); @@ -1380,8 +1365,7 @@ mod test { /end RECORD_LAYOUT /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT3, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT3, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1395,8 +1379,7 @@ mod test { STATUS_STRING_REF status_string_ref /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid compu tab ref, ref unit, and status string ref @@ -1407,8 +1390,7 @@ mod test { /begin COMPU_METHOD cm "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1437,8 +1419,7 @@ mod test { /end SUB_FUNCTION /end FUNCTION /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid in measurement, loc measurement, out measurement, def characteristic, @@ -1450,8 +1431,7 @@ mod test { /begin FUNCTION f "" /end FUNCTION /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1474,8 +1454,7 @@ mod test { /end SUB_GROUP /end GROUP /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid ref characteristic, ref measurement, function list, and sub group @@ -1495,8 +1474,7 @@ mod test { /end SUB_GROUP /end GROUP /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); @@ -1515,8 +1493,7 @@ mod test { /end SUB_GROUP /end GROUP /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); @@ -1535,8 +1512,7 @@ mod test { /end SUB_GROUP /end GROUP /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT3, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT3, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 1); } @@ -1551,8 +1527,7 @@ mod test { /end FUNCTION_LIST /end MEASUREMENT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid conversion, memory segment, and function list @@ -1565,8 +1540,7 @@ mod test { /begin TYPEDEF_MEASUREMENT tm "" UBYTE conversion 1 1 0 100 /end TYPEDEF_MEASUREMENT /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid conversion @@ -1585,8 +1559,7 @@ mod test { /end TRANSFORMER_OUT_OBJECTS /end TRANSFORMER /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid inverse transformer, transformer in objects, and transformer out objects @@ -1597,8 +1570,7 @@ mod test { /begin TRANSFORMER transformer_name "version string" "dll32" "dll64" 1 ON_CHANGE NO_INVERSE_TRANSFORMER /end TRANSFORMER /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT2, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT2, None, true).unwrap(); let log_msgs = super::check(&a2lfile); assert_eq!(log_msgs.len(), 0); } @@ -1609,8 +1581,7 @@ mod test { /begin INSTANCE i "" type_ref 0x1234 /end INSTANCE /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid type ref @@ -1625,8 +1596,7 @@ mod test { /end STRUCTURE_COMPONENT /end TYPEDEF_STRUCTURE /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid component type @@ -1754,8 +1724,7 @@ mod test { /begin COMPU_METHOD cm3 "" IDENTICAL "%4.2" "unit" /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut load_errors = Vec::new(); - let mut a2lfile = load_from_string(A2L_TEXT, None, &mut load_errors, true).unwrap(); + let (mut a2lfile, _) = load_from_string(A2L_TEXT, None, true).unwrap(); let log_msgs = super::check(&a2lfile); // invalid limits for each of CHARACTERISTIC, AXIS_DESCR, AXIS_PTS, and MEASUREMENT assert_eq!(log_msgs.len(), 4); diff --git a/a2lfile/src/cleanup.rs b/a2lfile/src/cleanup.rs index aae4445..90efbbf 100644 --- a/a2lfile/src/cleanup.rs +++ b/a2lfile/src/cleanup.rs @@ -138,8 +138,7 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let mut a2l_file = crate::load_from_string(a2l_text, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file, _) = crate::load_from_string(a2l_text, None, true).unwrap(); cleanup(&mut a2l_file); let module = &a2l_file.project.module[0]; diff --git a/a2lfile/src/lib.rs b/a2lfile/src/lib.rs index 69d50b2..a76d98b 100644 --- a/a2lfile/src/lib.rs +++ b/a2lfile/src/lib.rs @@ -190,10 +190,9 @@ If a definition is provided here and there is also an A2ML block in the file, th # Example ``` # use a2lfile::A2lError; -let mut log_msgs = Vec::::new(); -match a2lfile::load("example.a2l", None, &mut log_msgs, true) { - Ok(a2l_file) => {/* do something with it*/}, - Err(error_message) => println!("{}", error_message) +match a2lfile::load("example.a2l", None, true) { + Ok((a2l_file, log_messages)) => {/* do something with it*/}, + Err(error_message) => println!("{error_message}") } ``` @@ -204,12 +203,11 @@ An `A2lError` provides details information if loading the file fails. pub fn load>( path: P, a2ml_spec: Option, - log_msgs: &mut Vec, strict_parsing: bool, -) -> Result { +) -> Result<(A2lFile, Vec), A2lError> { let pathref = path.as_ref(); let filedata = loader::load(pathref)?; - load_impl(pathref, &filedata, log_msgs, strict_parsing, a2ml_spec) + load_impl(pathref, &filedata, strict_parsing, a2ml_spec) } /** @@ -228,6 +226,7 @@ If a definition is provided here and there is also an A2ML block in the file, th ```rust # use a2lfile::A2lError; +# fn main() -> Result<(), A2lError> { let text = r#" ASAP2_VERSION 1 71 /begin PROJECT new_project "" @@ -235,10 +234,10 @@ ASAP2_VERSION 1 71 /end MODULE /end PROJECT "#; - -let mut log_msgs = Vec::::new(); -let a2l = a2lfile::load_from_string(&text, None, &mut log_msgs, true).unwrap(); +let (a2l, log_msgs) = a2lfile::load_from_string(&text, None, true).unwrap(); assert_eq!(a2l.project.module[0].name, "new_module"); +# Ok(()) +# } ``` # Errors @@ -248,20 +247,19 @@ An `A2lError` provides details information if loading the data fails. pub fn load_from_string( a2ldata: &str, a2ml_spec: Option, - log_msgs: &mut Vec, strict_parsing: bool, -) -> Result { +) -> Result<(A2lFile, Vec), A2lError> { let pathref = Path::new(""); - load_impl(pathref, a2ldata, log_msgs, strict_parsing, a2ml_spec) + load_impl(pathref, a2ldata, strict_parsing, a2ml_spec) } fn load_impl( path: &Path, filedata: &str, - log_msgs: &mut Vec, strict_parsing: bool, a2ml_spec: Option, -) -> Result { +) -> Result<(A2lFile, Vec), A2lError> { + let mut log_msgs = Vec::::new(); // tokenize the input data let tokenresult = tokenizer::tokenize(&Filename::from(path), 0, filedata) .map_err(|tokenizer_error| A2lError::TokenizerError { tokenizer_error })?; @@ -273,7 +271,7 @@ fn load_impl( } // create the parser state object - let mut parser = ParserState::new(&tokenresult, log_msgs, strict_parsing); + let mut parser = ParserState::new(&tokenresult, &mut log_msgs, strict_parsing); // if a built-in A2ml specification was passed as a string, then it is parsed here if let Some(spec) = a2ml_spec { @@ -289,7 +287,7 @@ fn load_impl( .parse_file() .map_err(|parser_error| A2lError::ParserError { parser_error })?; - Ok(a2l_file) + Ok((a2l_file, log_msgs)) } /// load an a2l fragment @@ -515,8 +513,7 @@ mod tests { #[test] fn load_empty_file() { - let mut log_msgs = Vec::new(); - let result = load_from_string("", None, &mut log_msgs, false); + let result = load_from_string("", None, false); assert!(result.is_err()); let error = result.unwrap_err(); assert!(matches!(error, A2lError::EmptyFileError { .. })); @@ -539,24 +536,21 @@ mod tests { "#; std::fs::write(path, text).unwrap(); - let mut log_msgs = Vec::::new(); - let a2l = load(path, None, &mut log_msgs, false).unwrap(); + let (a2l, _) = load(path, None, false).unwrap(); assert_eq!(a2l.project.module[0].name, "new_module"); // try to load a file that does not exist let nonexistent_path = dir.path().join("nonexistent.a2l"); let nonexistent_path = nonexistent_path.to_str().unwrap(); - let result = load(nonexistent_path, None, &mut log_msgs, false); + let result = load(nonexistent_path, None, false); assert!(matches!(result, Err(A2lError::FileOpenError { .. }))); } #[test] fn bad_a2ml_data() { - let mut log_msgs = Vec::new(); let result = load_from_string( r#"/begin PROJECT x "" /begin MODULE y "" /end MODULE /end PROJECT"#, Some("x".to_string()), - &mut log_msgs, false, ); assert!(result.is_err()); @@ -567,11 +561,9 @@ mod tests { #[test] fn strict_parsing_version_error() { // version is missing completely - let mut log_msgs = Vec::new(); let result = load_from_string( r#"/begin PROJECT x "" /begin MODULE y "" /end MODULE /end PROJECT"#, None, - &mut log_msgs, true, ); assert!(result.is_err()); @@ -584,13 +576,7 @@ mod tests { )); // version is damaged - let mut log_msgs = Vec::new(); - let result = load_from_string( - r#"ASAP2_VERSION 1 /begin PROJECT"#, - None, - &mut log_msgs, - true, - ); + let result = load_from_string(r#"ASAP2_VERSION 1 /begin PROJECT"#, None, true); assert!(result.is_err()); let error = result.unwrap_err(); assert!(matches!( @@ -604,22 +590,19 @@ mod tests { #[test] fn additional_tokens() { // strict parsing off - no error - let mut log_msgs = Vec::new(); let result = load_from_string( r#"ASAP2_VERSION 1 71 /begin PROJECT x "" /begin MODULE y "" /end MODULE /end PROJECT abcdef"#, None, - &mut log_msgs, false, ); assert!(result.is_ok()); + let (_a2l, log_msgs) = result.unwrap(); assert_eq!(log_msgs.len(), 1); // strict parsing on - error - let mut log_msgs = Vec::new(); let result = load_from_string( r#"ASAP2_VERSION 1 71 /begin PROJECT x "" /begin MODULE y "" /end MODULE /end PROJECT abcdef"#, None, - &mut log_msgs, true, ); assert!(result.is_err()); diff --git a/a2lfile/src/merge.rs b/a2lfile/src/merge.rs index 8b2f8d1..82906a4 100644 --- a/a2lfile/src/merge.rs +++ b/a2lfile/src/merge.rs @@ -1139,16 +1139,15 @@ mod test { static FILE_B: &str = r#"/begin PROJECT p "" /begin MODULE m "" /begin A2ML block "IF_DATA" struct { int; }; /end A2ML /end MODULE /end PROJECT"#; static FILE_C: &str = r#"/begin PROJECT p "" /begin MODULE m "" /begin A2ML block "IF_DATA" struct { float; }; /end A2ML /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); // merging B into A: A2ML is copied a2l_file_a.merge_modules(&mut a2l_file_b); assert!(a2l_file_a.project.module[0].a2ml.is_some()); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); let orig_txt = a2l_file_b.project.module[0] .a2ml .as_ref() @@ -1226,18 +1225,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no MEASUREMENT, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); assert!(a2l_file_a.project.module[0].measurement.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].measurement.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); assert_eq!(a2l_file_b.project.module[0].measurement.len(), 1); assert_eq!(a2l_file_c.project.module[0].measurement.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1318,18 +1315,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no MEASUREMENT, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].measurement.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].typedef_measurement.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].typedef_measurement.len(), 1); assert_eq!(a2l_file_c.project.module[0].typedef_measurement.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1395,18 +1390,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no CHARACTERISTIC, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].characteristic.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].characteristic.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); assert_eq!(a2l_file_b.project.module[0].characteristic.len(), 1); assert_eq!(a2l_file_c.project.module[0].characteristic.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1497,11 +1490,9 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no CHARACTERISTIC, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0] .typedef_characteristic .is_empty()); @@ -1509,8 +1500,8 @@ mod test { assert_eq!(a2l_file_a.project.module[0].typedef_characteristic.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].typedef_characteristic.len(), 1); assert_eq!(a2l_file_c.project.module[0].typedef_characteristic.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1565,18 +1556,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no AXIS_PTS, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].axis_pts.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].axis_pts.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].axis_pts.len(), 1); assert_eq!(a2l_file_c.project.module[0].axis_pts.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1626,18 +1615,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no AXIS_PTS, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].typedef_axis.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].typedef_axis.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].typedef_axis.len(), 1); assert_eq!(a2l_file_c.project.module[0].typedef_axis.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1669,18 +1656,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no BLOB, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].blob.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].blob.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].blob.len(), 1); assert_eq!(a2l_file_c.project.module[0].blob.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1720,18 +1705,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no BLOB, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].typedef_blob.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].typedef_blob.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].typedef_blob.len(), 1); assert_eq!(a2l_file_c.project.module[0].typedef_blob.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1761,18 +1744,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no BLOB, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].typedef_structure.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].typedef_structure.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].typedef_structure.len(), 1); assert_eq!(a2l_file_c.project.module[0].typedef_structure.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1806,18 +1787,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no INSTANCE, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].instance.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].instance.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].instance.len(), 1); assert_eq!(a2l_file_c.project.module[0].instance.len(), 2); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1868,18 +1847,16 @@ mod test { /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - // merging B into A -> A has no MOD_PAR, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].mod_par.is_none()); a2l_file_a.merge_modules(&mut a2l_file_b); assert!(a2l_file_a.project.module[0].mod_par.is_some()); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert!(a2l_file_b.project.module[0].mod_par.is_some()); assert!(a2l_file_c.project.module[0].mod_par.is_some()); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -1900,7 +1877,6 @@ mod test { #[test] fn test_merge_compu_method() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"/begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"/begin PROJECT p "" /begin MODULE m "" @@ -1954,15 +1930,15 @@ mod test { /end PROJECT"#; // merging B into A -> A has no COMPU_METHODs, so they are all taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].compu_method.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].compu_method.len(), 1); // merging C into B: m1 is present in both, but with different content -> m1 is renamed - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].compu_method.len(), 1); a2l_file_b.merge_modules(&mut a2l_file_c); assert_eq!(a2l_file_b.project.module[0].compu_method.len(), 3); @@ -2014,7 +1990,6 @@ mod test { #[test] fn test_merge_compu_tab() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"ASAP2_VERSION 1 71 @@ -2080,8 +2055,8 @@ mod test { /end PROJECT"#; // merging B into A -> A has no COMPU_TABs, so they are all taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); assert!(a2l_file_a.project.module[0].compu_tab.is_empty()); assert!(a2l_file_a.project.module[0].compu_vtab.is_empty()); assert!(a2l_file_a.project.module[0].compu_vtab_range.is_empty()); @@ -2091,8 +2066,8 @@ mod test { assert_eq!(a2l_file_a.project.module[0].compu_vtab_range.len(), 2); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_c); assert_eq!(a2l_file_b.project.module[0].compu_tab.len(), 3); @@ -2102,7 +2077,6 @@ mod test { #[test] fn test_merge_unit() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"/begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"/begin PROJECT p "" /begin MODULE m "" @@ -2129,15 +2103,15 @@ mod test { /end PROJECT"#; // merging B into A -> A has no UNIT, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].unit.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].unit.len(), 2); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].unit.len(), 2); assert_eq!(a2l_file_c.project.module[0].unit.len(), 3); a2l_file_b.merge_modules(&mut a2l_file_c); @@ -2164,7 +2138,6 @@ mod test { #[test] fn test_merge_record_layout() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"/begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"/begin PROJECT p "" /begin MODULE m "" @@ -2202,15 +2175,15 @@ mod test { /end PROJECT"#; // merging B into A -> A has no RECORD_LAYOUT, so it is taken from B - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); assert!(a2l_file_a.project.module[0].record_layout.is_empty()); a2l_file_a.merge_modules(&mut a2l_file_b); assert_eq!(a2l_file_a.project.module[0].record_layout.len(), 1); // merging C into B - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, false).unwrap(); assert_eq!(a2l_file_b.project.module[0].record_layout.len(), 1); a2l_file_b.merge_modules(&mut a2l_file_c); assert_eq!(a2l_file_b.project.module[0].record_layout.len(), 3); @@ -2263,20 +2236,19 @@ mod test { /end MOD_COMMON /end MODULE /end PROJECT"#; - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_d = load_from_string(FILE_D, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_d, _) = load_from_string(FILE_D, None, false).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_d); assert_eq!(a2l_file_b.project.module[0].record_layout.len(), 2); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, false).unwrap(); - let mut a2l_file_e = load_from_string(FILE_E, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, false).unwrap(); + let (mut a2l_file_e, _) = load_from_string(FILE_E, None, false).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_e); assert_eq!(a2l_file_b.project.module[0].record_layout.len(), 2); } #[test] fn merge_group() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /begin MEASUREMENT m1 "" FLOAT32_IEEE NO_COMPU_METHOD 1 1.0 0 100 /end MEASUREMENT @@ -2332,8 +2304,8 @@ mod test { /end GROUP /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); @@ -2379,7 +2351,6 @@ mod test { #[test] fn merge_function() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /begin MEASUREMENT m1 "" FLOAT32_IEEE NO_COMPU_METHOD 1 1.0 0 100 /end MEASUREMENT @@ -2423,8 +2394,8 @@ mod test { /end FUNCTION /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); @@ -2477,7 +2448,6 @@ mod test { #[test] fn test_merge_module_ifdata() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" @@ -2491,14 +2461,14 @@ mod test { /end IF_DATA /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); // since file A has no IF_DATA, it is taken from B assert_eq!(a2l_file_a.project.module[0].if_data.len(), 1); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_c); // file B already has IF_DATA, so the ones from C are ignored assert_eq!(a2l_file_b.project.module[0].if_data.len(), 1); @@ -2506,7 +2476,6 @@ mod test { #[test] fn test_merge_frame() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" @@ -2520,14 +2489,14 @@ mod test { /end FRAME /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); // since file A has no FRAME, it is taken from B assert_eq!(a2l_file_a.project.module[0].frame.len(), 1); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_c); // frames from B and C are merged. // frame1 is present in both, but with different content -> frame1 is renamed @@ -2537,7 +2506,6 @@ mod test { #[test] fn test_merge_transformer() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" @@ -2551,14 +2519,14 @@ mod test { /end TRANSFORMER /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); // since file A has no TRANSFORMER, it is taken from B assert_eq!(a2l_file_a.project.module[0].transformer.len(), 1); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_c); // transformers from B and C are merged. // transformer1 is present in both, but with different content -> transformer1 is renamed @@ -2577,7 +2545,6 @@ mod test { #[test] fn test_merge_user_rights() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT"#; static FILE_B: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" @@ -2592,14 +2559,14 @@ mod test { /end USER_RIGHTS /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); // since file A has no USER_RIGHTS, it is taken from B assert_eq!(a2l_file_a.project.module[0].user_rights.len(), 1); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_c = load_from_string(FILE_C, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); + let (mut a2l_file_c, _) = load_from_string(FILE_C, None, true).unwrap(); a2l_file_b.merge_modules(&mut a2l_file_c); // user_rights from B and C are merged. // user1 is already present in B, so the new copy from C is ignored @@ -2615,7 +2582,6 @@ mod test { #[test] fn test_make_unique_name() { - let mut log_msgs = vec![]; static FILE_A: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /begin MEASUREMENT m1 "" FLOAT32_IEEE NO_COMPU_METHOD 1 1.0 0 100 /end MEASUREMENT @@ -2627,8 +2593,8 @@ mod test { /end MEASUREMENT /end MODULE /end PROJECT"#; - let mut a2l_file_a = load_from_string(FILE_A, None, &mut log_msgs, true).unwrap(); - let mut a2l_file_b = load_from_string(FILE_B, None, &mut log_msgs, true).unwrap(); + let (mut a2l_file_a, _) = load_from_string(FILE_A, None, true).unwrap(); + let (mut a2l_file_b, _) = load_from_string(FILE_B, None, true).unwrap(); a2l_file_a.merge_modules(&mut a2l_file_b); // the MEASUREMENT m1 in B is renamed, because it is not identical to the one in A diff --git a/a2lfile/src/namemap.rs b/a2lfile/src/namemap.rs index 4e12938..ee7d864 100644 --- a/a2lfile/src/namemap.rs +++ b/a2lfile/src/namemap.rs @@ -477,8 +477,7 @@ mod test { /end UNIT /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_unit = build_namemap_unit(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 1); @@ -514,8 +513,7 @@ mod test { /end TYPEDEF_STRUCTURE /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_typedef = build_namemap_typedef(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 5); @@ -553,8 +551,7 @@ mod test { /end RECORD_LAYOUT /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_record_layout = build_namemap_record_layout(&a2l_file.project.module[0], &mut log_msgs); @@ -579,8 +576,7 @@ mod test { /end MOD_PAR /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_memory_segment = build_namemap_memory_segment(&a2l_file.project.module[0], &mut log_msgs); @@ -611,8 +607,7 @@ mod test { /end COMPU_VTAB_RANGE /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_compu_tab = build_namemap_compu_tab(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 3); @@ -642,8 +637,7 @@ mod test { /end COMPU_METHOD /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_compu_method = build_namemap_compu_method(&a2l_file.project.module[0], &mut log_msgs); @@ -666,8 +660,7 @@ mod test { /end TRANSFORMER /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_transformer = build_namemap_transformer(&a2l_file.project.module[0], &mut log_msgs); @@ -706,8 +699,7 @@ mod test { /end INSTANCE /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_object = build_namemap_object(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 5); @@ -749,8 +741,7 @@ mod test { /end VARIANT_CODING /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_variant = build_namemap_variant(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 1); @@ -772,8 +763,7 @@ mod test { /end GROUP /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_group = build_namemap_group(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 1); @@ -792,8 +782,7 @@ mod test { /end FRAME /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_frame = build_namemap_frame(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 1); @@ -812,8 +801,7 @@ mod test { /end FUNCTION /end MODULE /end PROJECT"#; - let mut log_msgs = Vec::new(); - let a2l_file = crate::load_from_string(DATA, None, &mut log_msgs, true).unwrap(); + let (a2l_file, _) = crate::load_from_string(DATA, None, true).unwrap(); let mut log_msgs = Vec::new(); let namemap_function = build_namemap_function(&a2l_file.project.module[0], &mut log_msgs); assert_eq!(log_msgs.len(), 1); diff --git a/a2lfile/src/parser.rs b/a2lfile/src/parser.rs index 8def984..291fd2a 100644 --- a/a2lfile/src/parser.rs +++ b/a2lfile/src/parser.rs @@ -1378,8 +1378,7 @@ mod tests { #[test] fn error_missing_version() { static DATA: &str = r#"/begin PROJECT p "" /end PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(a2l_file.is_err()); assert!(matches!( a2l_file, @@ -1392,8 +1391,7 @@ mod tests { #[test] fn error_invalid_mult_not_present() { static DATA: &str = r#"ASAP2_VERSION 1 71"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(matches!( a2l_file, Err(A2lError::ParserError { @@ -1405,8 +1403,7 @@ mod tests { #[test] fn error_invalid_mult_too_many() { static DATA: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MODULE /end PROJECT /begin PROJECT p2 "" /begin MODULE m "" /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(matches!( a2l_file, Err(A2lError::ParserError { @@ -1418,8 +1415,7 @@ mod tests { #[test] fn error_unknown_subblock() { static DATA: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" ABCDEF /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(matches!( a2l_file, Err(A2lError::ParserError { @@ -1432,8 +1428,7 @@ mod tests { fn error_incorrect_end_tag() { static DATA: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /end MMMMM /end PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(matches!( a2l_file, Err(A2lError::ParserError { @@ -1445,8 +1440,7 @@ mod tests { #[test] fn error_unexpected_eof() { static DATA: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT"#; - let mut log_msgs = vec![]; - let a2l_file = load_from_string(DATA, None, &mut log_msgs, true); + let a2l_file = load_from_string(DATA, None, true); assert!(matches!( a2l_file, Err(A2lError::ParserError { @@ -1461,8 +1455,7 @@ mod tests { r#"ASAP2_VERSION 1 71 /begin PROJECT {} "" /begin MODULE m "" /end MODULE /end PROJECT"#, ['a'; 1025].iter().collect::() ); - let mut log_msgs = vec![]; - let a2l_file = load_from_string(&data, None, &mut log_msgs, true); + let a2l_file = load_from_string(&data, None, true); println!("a2l_file: {:#?}", a2l_file); assert!(a2l_file.is_err()); assert!(matches!( @@ -1479,18 +1472,16 @@ mod tests { static DATA: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /begin UNKNOWN_TAG abc def /begin ghi /end ghi /end UNKNOWN_TAG /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let result = load_from_string(DATA, None, &mut log_msgs, false); + let result = load_from_string(DATA, None, false); assert!(result.is_ok()); - let a2l_file = result.unwrap(); + let (a2l_file, _) = result.unwrap(); assert_eq!(a2l_file.project.module.len(), 1); // unbalanced unknown block static DATA2: &str = r#"ASAP2_VERSION 1 71 /begin PROJECT p "" /begin MODULE m "" /begin UNKNOWN_TAG abc def /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let result = load_from_string(DATA2, None, &mut log_msgs, false); + let result = load_from_string(DATA2, None, false); assert!(matches!( result, Err(A2lError::ParserError { @@ -1504,10 +1495,9 @@ mod tests { /begin GROUP group_name "" ROOT /end GROUP /end MODULE /end PROJECT"#; - let mut log_msgs = vec![]; - let result = load_from_string(DATA3, None, &mut log_msgs, false); + let result = load_from_string(DATA3, None, false); assert!(result.is_ok()); - let a2l_file = result.unwrap(); + let (a2l_file, _) = result.unwrap(); assert_eq!(a2l_file.project.module.len(), 1); assert_eq!(a2l_file.project.module[0].group.len(), 1); } diff --git a/a2lfile/tests/test.rs b/a2lfile/tests/test.rs index 3c77e85..58727b8 100644 --- a/a2lfile/tests/test.rs +++ b/a2lfile/tests/test.rs @@ -68,8 +68,7 @@ ASAP2_VERSION 1 61 #[test] fn round_trip() { - let mut log_msgs = Vec::::new(); - let a2lfile = a2lfile::load_from_string(TEST_A2L, None, &mut log_msgs, false).unwrap(); + let (a2lfile, _) = a2lfile::load_from_string(TEST_A2L, None, false).unwrap(); let text = a2lfile.write_to_string(); println!("input:\n{}\noutput:\n{}\n", TEST_A2L, text); @@ -761,9 +760,7 @@ ASAP2_VERSION 1 61 assert_eq!(a2l_file, unchanged_a2l_file); assert_eq!(a2l_file.project.module.len(), 1); - let mut log_msgs = Vec::::new(); - let mut other_a2l_file = - a2lfile::load_from_string(TEST_A2L, None, &mut log_msgs, false).unwrap(); + let (mut other_a2l_file, _) = a2lfile::load_from_string(TEST_A2L, None, false).unwrap(); assert_eq!(a2l_file.project.module[0].measurement.len(), 1); a2l_file.merge_modules(&mut other_a2l_file); assert_eq!(a2l_file.project.module[0].measurement.len(), 2); @@ -816,19 +813,13 @@ ASAP2_VERSION 1 61 assert!(std::path::Path::new("test.a2l").exists()); // verify that the loaded data structure is identical to the original data structure - let mut log_msgs = Vec::::new(); - let a2l_file2 = a2lfile::load_from_string(&a2ldata, None, &mut log_msgs, false); + let a2l_file2 = a2lfile::load_from_string(&a2ldata, None, false); assert!(a2l_file2.is_ok()); - let a2l_file2 = a2l_file2.unwrap(); + let (a2l_file2, _) = a2l_file2.unwrap(); assert_eq!(a2l_file, a2l_file2); - let mut a2l_file3 = a2lfile::load( - "test.a2l", - Some(A2MLTEST_TEXT.to_string()), - &mut log_msgs, - false, - ) - .unwrap(); + let (mut a2l_file3, _) = + a2lfile::load("test.a2l", Some(A2MLTEST_TEXT.to_string()), false).unwrap(); assert_eq!(a2l_file2, a2l_file3); // set the incfile propery of one element. This would normally indicate that is was loaded from an /include file @@ -864,56 +855,48 @@ ASAP2_VERSION 1 61 #[test] fn parsing_weird_data() { let data_bad = r##"abcdef"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_bad, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_bad, None, false); assert!(load_result.is_err()); let data_bad = r##"ASAP2_VERSION 1 71"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_bad, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_bad, None, false); assert!(load_result.is_err()); let data_bad = r##"ASAP2_VERSION 1 71 /begin PROJECT /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_bad, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_bad, None, false); assert!(load_result.is_err()); let data_bad = r##"ASAP2_VERSION 1 71 /begin PROJECT //x "" /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_bad, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_bad, None, false); assert!(load_result.is_err()); let data_bad = r##"ASAP2_VERSION 1 71 /beginPROJECT x "" /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_bad, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_bad, None, false); assert!(load_result.is_err()); let data_good = r##"ASAP2_VERSION 1 0x47 /begin PROJECT x "" /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_good, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_good, None, false); assert!(load_result.is_ok()); let data_good = r##"ASAP2_VERSION 1 71 /begin PROJECT x "" /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_good, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_good, None, false); assert!(load_result.is_ok()); let data_good = r##"//comment ASAP2_VERSION 1 71 //comment /begin PROJECT x "" /*/*////* /end PROJECT"##; - let mut log_msgs = Vec::::new(); - let load_result = a2lfile::load_from_string(data_good, None, &mut log_msgs, false); + let load_result = a2lfile::load_from_string(data_good, None, false); assert!(load_result.is_ok()); } @@ -1261,14 +1244,13 @@ ASAP2_VERSION 1 61 #[cfg(all(feature = "check", feature = "sort"))] #[test] fn specification_test() { - let mut log_msgs = Vec::new(); - let mut a2l_file = load_from_string(TEST_A2L_2, None, &mut log_msgs, false).unwrap(); + let (mut a2l_file, _) = load_from_string(TEST_A2L_2, None, false).unwrap(); let mut a2l_file2 = a2l_file.clone(); assert_eq!(a2l_file, a2l_file2); let serialized = a2l_file2.write_to_string(); // unfortunately minor formatting differences (whitespace, floats) prevent comparison of the serialized text - let a2l_file3 = load_from_string(&serialized, None, &mut log_msgs, false).unwrap(); + let (a2l_file3, _) = load_from_string(&serialized, None, false).unwrap(); assert_eq!(a2l_file, a2l_file3); // reset the location, serialize & reload again @@ -1277,7 +1259,7 @@ ASAP2_VERSION 1 61 a2l_file2.project.module[0].reset_location(); a2l_file2.project.module[0].characteristic[0].reset_location(); let serialized2 = a2l_file2.write_to_string(); - let a2l_file4 = load_from_string(&serialized2, None, &mut log_msgs, false).unwrap(); + let (a2l_file4, _) = load_from_string(&serialized2, None, false).unwrap(); // serialized text is not equal, because location info was reset with reset_location() and some elements were arranged differently assert_ne!(serialized, serialized2); // the files are still equal, because location info is not considered when comparing data @@ -1896,7 +1878,7 @@ ASAP2_VERSION 1 61 // verify store + load round trip of newly created data let serialized3 = a2l_file5.write_to_string(); - let a2l_file6 = load_from_string(&serialized3, None, &mut log_msgs, false).unwrap(); + let (a2l_file6, _) = load_from_string(&serialized3, None, false).unwrap(); assert_eq!(a2l_file, a2l_file6); let mut a2l_file7 = a2l_file5.clone(); @@ -1941,8 +1923,7 @@ ASAP2_VERSION 1 61 /end MODULE /end PROJECT "#; - let mut log_msgs = Vec::::new(); - let a2lfile = a2lfile::load_from_string(a2l, None, &mut log_msgs, false).unwrap(); + let (a2lfile, _) = a2lfile::load_from_string(a2l, None, false).unwrap(); let measurement = &a2lfile.project.module[0].measurement[0]; assert_eq!(