use crate::model::raw_file::RawFile;
#[macro_use]
mod macros;
pub mod ordered_serialization;
#[test]
fn test_empty_raw_files() {
let raw_files = vec![];
assert_indexed_files!("empty_raw_files", raw_files);
}
#[test]
fn test_raw_file_with_no_lines() {
let raw_files = vec![RawFile {
filename: "raw_file_filename".to_string(),
lines: vec![],
}];
assert_indexed_files!("raw_file_with_no_lines", raw_files);
}
#[test]
fn test_indexed_file_stores_correct_line_number() {
let raw_files = vec![RawFile {
filename: "raw_file_filename".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
}];
assert_indexed_files!("indexed_file_stores_correct_line_number", raw_files);
}
#[test]
fn test_indexed_files_consistent_ordering() {
let raw_files_1 = 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(),
],
},
];
let raw_files_2 = vec![
RawFile {
filename: "raw_file_filename_2".to_string(),
lines: vec![
"line 4".to_string(),
"line 5".to_string(),
"line 6".to_string(),
],
},
RawFile {
filename: "raw_file_filename_1".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
},
];
assert_indexed_files!("indexed_files_consistent_ordering", raw_files_1);
assert_indexed_files!("indexed_files_consistent_ordering", raw_files_2);
}
#[test]
fn test_indexed_file_ignore_line_regex() {
let raw_files = vec![RawFile {
filename: "raw_file_filename".to_string(),
lines: vec![
"line 1".to_string(),
"line 2".to_string(),
"line 3".to_string(),
],
}];
let ignore_line_regex = vec!["^line 1".to_string()];
assert_indexed_files_with_ignore_line_regex!(
"indexed_file_ignore_line_regex",
ignore_line_regex,
raw_files
);
}