From 14c0785a8995e1b617a556418688b0dd1f056427 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 14 Sep 2022 12:24:35 +0200 Subject: [PATCH] Start curve approximation test suite It's just a single, simple test so far. I had planned to add more, but it turns out that they aren't easy to write, due to bugs and inconsistencies: https://github.com/hannobraun/Fornjot/issues/1079#issuecomment-1246622675 This is going to be much easier to fix, once #1079 is addressed, so I'm just going ahead with that instead. --- .../fj-kernel/src/algorithms/approx/curve.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 775d02d42..9a320cfae 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -130,3 +130,27 @@ pub struct GlobalCurveApprox { /// The points that approximate the curve pub points: Vec>, } + +#[cfg(test)] +mod tests { + + use crate::{ + algorithms::approx::{path::RangeOnPath, Approx}, + objects::{Curve, Surface}, + path::GlobalPath, + }; + + use super::CurveApprox; + + #[test] + fn approx_line_on_flat_surface() { + let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); + let curve = + Curve::build(surface).line_from_points([[1., 1.], [2., 1.]]); + let range = RangeOnPath::from([[0.], [1.]]); + + let approx = (&curve, range).approx(1.); + + assert_eq!(approx, CurveApprox::empty()) + } +}