Split integration tests
This commit is contained in:
parent
f747634aac
commit
f509a60f0a
1 changed files with 48 additions and 34 deletions
|
|
@ -7,12 +7,57 @@ use reconcile::{reconcile, reconcile_with_cursors};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_with_examples() {
|
fn test_document_one_way_without_cursors() {
|
||||||
|
get_all_documents().iter().for_each(|doc| {
|
||||||
|
doc.assert_eq_without_cursors(&reconcile(
|
||||||
|
&doc.parent(),
|
||||||
|
&doc.left().text,
|
||||||
|
&doc.right().text,
|
||||||
|
))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_document_one_way_with_cursors() {
|
||||||
|
get_all_documents().iter().for_each(|doc| {
|
||||||
|
doc.assert_eq(&reconcile_with_cursors(
|
||||||
|
&doc.parent(),
|
||||||
|
doc.left(),
|
||||||
|
doc.right(),
|
||||||
|
))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_document_inverse_way_without_cursors() {
|
||||||
|
get_all_documents().iter().for_each(|doc| {
|
||||||
|
doc.assert_eq_without_cursors(&reconcile(
|
||||||
|
&doc.parent(),
|
||||||
|
&doc.right().text,
|
||||||
|
&doc.left().text,
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_document_inverse_way_with_cursors() {
|
||||||
|
get_all_documents().iter().for_each(|doc| {
|
||||||
|
doc.assert_eq(&reconcile_with_cursors(
|
||||||
|
&doc.parent(),
|
||||||
|
doc.right(),
|
||||||
|
doc.left(),
|
||||||
|
))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_all_documents() -> Vec<ExampleDocument> {
|
||||||
let examples_dir = Path::new("tests/examples");
|
let examples_dir = Path::new("tests/examples");
|
||||||
let entries = fs::read_dir(examples_dir)
|
let entries = fs::read_dir(examples_dir)
|
||||||
.expect("Failed to read examples directory")
|
.expect("Failed to read examples directory")
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let mut documents = Vec::new();
|
||||||
|
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
let entry = entry.expect("Failed to read directory entry");
|
let entry = entry.expect("Failed to read directory entry");
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
@ -20,43 +65,12 @@ fn test_with_examples() {
|
||||||
if path.is_file() && path.extension().and_then(|ext| ext.to_str()) == Some("yml") {
|
if path.is_file() && path.extension().and_then(|ext| ext.to_str()) == Some("yml") {
|
||||||
let file = fs::File::open(&path).expect("Failed to open example file");
|
let file = fs::File::open(&path).expect("Failed to open example file");
|
||||||
for document in serde_yaml::Deserializer::from_reader(file) {
|
for document in serde_yaml::Deserializer::from_reader(file) {
|
||||||
println!("Testing with example from {}", path.display());
|
|
||||||
|
|
||||||
let doc =
|
let doc =
|
||||||
ExampleDocument::deserialize(document).expect("Failed to deserialize document");
|
ExampleDocument::deserialize(document).expect("Failed to deserialize document");
|
||||||
|
documents.push(doc);
|
||||||
test_document(doc);
|
|
||||||
|
|
||||||
println!("Test passed for example from {}", path.display());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
documents
|
||||||
fn test_document(doc: ExampleDocument) {
|
|
||||||
doc.assert_eq_without_cursors(&reconcile(
|
|
||||||
&doc.parent(),
|
|
||||||
&doc.left().text,
|
|
||||||
&doc.right().text,
|
|
||||||
));
|
|
||||||
|
|
||||||
doc.assert_eq(&reconcile_with_cursors(
|
|
||||||
&doc.parent(),
|
|
||||||
doc.left(),
|
|
||||||
doc.right(),
|
|
||||||
));
|
|
||||||
|
|
||||||
// inverse direction
|
|
||||||
doc.assert_eq_without_cursors(&reconcile(
|
|
||||||
&doc.parent(),
|
|
||||||
&doc.right().text,
|
|
||||||
&doc.left().text,
|
|
||||||
));
|
|
||||||
|
|
||||||
// inverse direction with cursors
|
|
||||||
doc.assert_eq(&reconcile_with_cursors(
|
|
||||||
&doc.parent(),
|
|
||||||
doc.right(),
|
|
||||||
doc.left(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue