Skip to content

Commit

Permalink
Merge pull request #1681 from hannobraun/tests
Browse files Browse the repository at this point in the history
Simplify some tests
  • Loading branch information
hannobraun authored Mar 13, 2023
2 parents 9bc7852 + 85ebe50 commit bb8069c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 56 deletions.
57 changes: 13 additions & 44 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ mod tests {
use fj_math::Point;

use crate::{
builder::CycleBuilder,
geometry::curve::Curve,
partial::{PartialCycle, PartialObject},
services::Services,
builder::HalfEdgeBuilder, geometry::curve::Curve, services::Services,
};

use super::CurveEdgeIntersection;
Expand All @@ -85,16 +82,9 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::new(&mut services.objects);

let [half_edge, _, _] = cycle.update_as_polygon_from_points(
[[1., -1.], [1., 1.], [0., 1.]],
&mut services.objects,
);

half_edge
};
let half_edge =
HalfEdgeBuilder::line_segment([[1., -1.], [1., 1.]], None)
.build(&mut services.objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -111,16 +101,9 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::new(&mut services.objects);

let [half_edge, _, _] = cycle.update_as_polygon_from_points(
[[-1., -1.], [-1., 1.], [0., 1.]],
&mut services.objects,
);

half_edge
};
let half_edge =
HalfEdgeBuilder::line_segment([[-1., -1.], [-1., 1.]], None)
.build(&mut services.objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -137,16 +120,9 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::new(&mut services.objects);

let [half_edge, _, _] = cycle.update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.]],
&mut services.objects,
);

half_edge
};
let half_edge =
HalfEdgeBuilder::line_segment([[-1., -1.], [1., -1.]], None)
.build(&mut services.objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -158,16 +134,9 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::new(&mut services.objects);

let [half_edge, _, _] = cycle.update_as_polygon_from_points(
[[-1., 0.], [1., 0.], [1., 1.]],
&mut services.objects,
);

half_edge
};
let half_edge =
HalfEdgeBuilder::line_segment([[-1., 0.], [1., 0.]], None)
.build(&mut services.objects);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand Down
15 changes: 3 additions & 12 deletions crates/fj-kernel/src/validate/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ mod tests {
use fj_math::Point;

use crate::{
builder::CycleBuilder,
builder::HalfEdgeBuilder,
objects::HalfEdge,
partial::{PartialCycle, PartialObject},
services::Services,
validate::{HalfEdgeValidationError, Validate, ValidationError},
};
Expand All @@ -87,16 +86,8 @@ mod tests {
fn half_edge_vertices_are_coincident() -> anyhow::Result<()> {
let mut services = Services::new();

let valid = {
let mut cycle = PartialCycle::new(&mut services.objects);

let [half_edge, _, _] = cycle.update_as_polygon_from_points(
[[0., 0.], [1., 0.], [1., 1.]],
&mut services.objects,
);

half_edge
};
let valid = HalfEdgeBuilder::line_segment([[0., 0.], [1., 0.]], None)
.build(&mut services.objects);
let invalid = {
let boundary = [Point::from([0.]); 2];

Expand Down

0 comments on commit bb8069c

Please sign in to comment.