Skip to content

Commit

Permalink
Handle errors in unit tests
Browse files Browse the repository at this point in the history
Honestly, I don't understand how that worked in the first place. Must be
some kind of iterator magic.
  • Loading branch information
hannobraun committed Nov 9, 2022
1 parent ea5efa6 commit 2265682
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions crates/fj-kernel/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ mod tests {
use super::ObjectIters as _;

#[test]
fn curve() {
fn curve() -> anyhow::Result<()> {
let objects = Objects::new();

let surface = objects.surfaces.xy_plane();
let object = Curve::partial()
.with_surface(Some(surface))
.update_as_u_axis()
.build(&objects);
.build(&objects)?;

assert_eq!(1, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count());
Expand All @@ -391,10 +391,12 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(0, object.surface_iter().count());
assert_eq!(0, object.vertex_iter().count());

Ok(())
}

#[test]
fn cycle() {
fn cycle() -> anyhow::Result<()> {
let objects = Objects::new();

let surface = objects.surfaces.xy_plane();
Expand All @@ -404,7 +406,7 @@ mod tests {
[[0., 0.], [1., 0.], [0., 1.]],
)
.close_with_line_segment()
.build(&objects);
.build(&objects)?;

assert_eq!(3, object.curve_iter().count());
assert_eq!(1, object.cycle_iter().count());
Expand All @@ -417,17 +419,19 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(0, object.surface_iter().count());
assert_eq!(6, object.vertex_iter().count());

Ok(())
}

#[test]
fn face() {
fn face() -> anyhow::Result<()> {
let objects = Objects::new();

let surface = objects.surfaces.xy_plane();
let object = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.build(&objects);
.build(&objects)?;

assert_eq!(3, object.curve_iter().count());
assert_eq!(1, object.cycle_iter().count());
Expand All @@ -440,13 +444,15 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(1, object.surface_iter().count());
assert_eq!(6, object.vertex_iter().count());

Ok(())
}

#[test]
fn global_curve() {
fn global_curve() -> anyhow::Result<()> {
let objects = Objects::new();

let object = objects.global_curves.insert(GlobalCurve);
let object = objects.global_curves.insert(GlobalCurve)?;

assert_eq!(0, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count());
Expand All @@ -459,15 +465,17 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(0, object.surface_iter().count());
assert_eq!(0, object.vertex_iter().count());

Ok(())
}

#[test]
fn global_vertex() {
fn global_vertex() -> anyhow::Result<()> {
let objects = Objects::new();

let object = objects
.global_vertices
.insert(GlobalVertex::from_position([0., 0., 0.]));
.insert(GlobalVertex::from_position([0., 0., 0.]))?;

assert_eq!(0, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count());
Expand All @@ -480,18 +488,20 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(0, object.surface_iter().count());
assert_eq!(0, object.vertex_iter().count());

Ok(())
}

#[test]
fn half_edge() {
fn half_edge() -> anyhow::Result<()> {
let objects = Objects::new();

let object = HalfEdge::partial()
.update_as_line_segment_from_points(
objects.surfaces.xy_plane(),
[[0., 0.], [1., 0.]],
)
.build(&objects);
.build(&objects)?;

assert_eq!(1, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count());
Expand All @@ -504,6 +514,8 @@ mod tests {
assert_eq!(0, object.solid_iter().count());
assert_eq!(0, object.surface_iter().count());
assert_eq!(2, object.vertex_iter().count());

Ok(())
}

#[test]
Expand Down

0 comments on commit 2265682

Please sign in to comment.