use crate::model::raw_file::RawFile;
#[macro_use]
mod macros;
#[test]
fn test_empty_hashed_files() {
let raw_files = vec![];
assert_duplicates!("empty_hashed_files", raw_files);
}
#[test]
fn test_hashed_file_with_no_lines() {
let raw_files = vec![RawFile {
filename: "raw_file_filename".to_string(),
lines: vec![],
}];
assert_duplicates!("hashed_file_with_no_lines", raw_files);
}
#[test]
fn test_hashed_files_with_no_lines() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![],
},
];
assert_duplicates!("hashed_files_with_no_lines", raw_files);
}
#[test]
fn test_hashed_files_with_no_duplicate() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 4".to_string(),
"line 5".to_string(),
"line 6".to_string(),
],
},
];
assert_duplicates!("hashed_files_with_no_duplicate", raw_files);
}
#[test]
fn test_hashed_files_with_duplicate() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
];
assert_duplicates!("hashed_files_with_duplicate", raw_files);
}
#[test]
fn test_hashed_files_with_duplicate_on_different_lines() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"precursor 1".to_string(),
"precursor 2".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"line 4".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"successor 1".to_string(),
],
},
];
assert_duplicates!("hashed_files_with_duplicate_on_different_lines", raw_files);
}
#[test]
fn test_hashed_files_and_empty_with_duplicate_on_different_lines() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"precursor 1".to_string(),
"precursor 2".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"line 4".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![],
},
RawFile {
filename: "raw_file_filename_3".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"successor 1".to_string(),
],
},
];
assert_duplicates!(
"hashed_files_and_empty_with_duplicate_on_different_lines",
raw_files
);
}
#[test]
fn test_hashed_files_with_multiple_duplicate_in_different_files() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"precursor 1".to_string(),
"precursor 2".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"line 4".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"successor 1".to_string(),
],
},
RawFile {
filename: "raw_file_filename_3".to_string(),
lines: vec![
"precursor 1".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"successor 1".to_string(),
],
},
];
assert_duplicates!(
"hashed_files_with_multiple_duplicate_in_different_files",
raw_files
);
}
#[test]
fn test_hashed_files_with_ignore_line_regex() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"precursor 1".to_string(),
"precursor 2".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"line 4".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"successor 1".to_string(),
],
},
];
let ignore_line_regex = vec!["^precursor".to_string(), "^successor".to_string()];
assert_duplicates_with_ignore_line_regex!(
"hashed_files_with_duplicate_on_different_lines",
ignore_line_regex,
raw_files
);
}
#[test]
fn test_hashed_files_with_duplicate_with_multiple_occurrences() {
let raw_files = vec![
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"precursor 1".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
"breaker 1".to_string(),
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
];
assert_duplicates!(
"hashed_files_with_duplicate_with_multiple_occurrences",
raw_files
);
}