Move test closer to code under test

This commit is contained in:
Hanno Braun 2024-05-21 21:56:33 +02:00
parent f165c25faa
commit ad06804675
2 changed files with 34 additions and 22 deletions

View File

@ -271,28 +271,6 @@ mod tests {
Core,
};
#[test]
fn half_edge_has_no_sibling() -> anyhow::Result<()> {
let mut core = Core::new();
let valid = Shell::tetrahedron(
[[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]],
&mut core,
);
let invalid = valid.shell.remove_face(&valid.abc.face);
valid
.shell
.validate_and_return_first_error(&core.layers.geometry)?;
assert_contains_err!(
core,
invalid,
ValidationError::HalfEdgeHasNoSibling { .. }
);
Ok(())
}
#[test]
fn coincident_half_edges_are_not_siblings() -> anyhow::Result<()> {
let mut core = Core::new();

View File

@ -72,3 +72,37 @@ impl ValidationCheck<Shell> for HalfEdgeHasNoSibling {
.map(|half_edge| HalfEdgeHasNoSibling { half_edge })
}
}
#[cfg(test)]
mod tests {
use crate::{
assert_contains_err,
operations::{build::BuildShell, update::UpdateShell},
topology::Shell,
validate::Validate,
validation::ValidationError,
Core,
};
#[test]
fn half_edge_has_no_sibling() -> anyhow::Result<()> {
let mut core = Core::new();
let valid = Shell::tetrahedron(
[[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]],
&mut core,
);
let invalid = valid.shell.remove_face(&valid.abc.face);
valid
.shell
.validate_and_return_first_error(&core.layers.geometry)?;
assert_contains_err!(
core,
invalid,
ValidationError::HalfEdgeHasNoSibling { .. }
);
Ok(())
}
}