Skip to content

Commit

Permalink
test: add tests for checking error with bspline wrt to degree and dat…
Browse files Browse the repository at this point in the history
…a/control points
  • Loading branch information
sathvikbhagavan committed Jul 7, 2024
1 parent 2fe49b3 commit 19b1db9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/interpolation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,12 @@ end
@test [A(190.0), A(225.0)] == [13.437481084762863, 11.367034741256463]
@test [A(t[1]), A(t[end])] == [u[1], u[end]]

@test_throws ErrorException("BSplineInterpolation needs at least d + 1, i.e. 4 points.") BSplineInterpolation(
u[1:3], t[1:3], 3, :Uniform, :Uniform)
@test_throws ErrorException("BSplineInterpolation needs at least d + 1, i.e. 5 points.") BSplineInterpolation(
u[1:4], t[1:4], 4, :ArcLen, :Average)
@test_nowarn BSplineInterpolation(u[1:3], t[1:3], 2, :Uniform, :Uniform)

# Test extrapolation
A = BSplineInterpolation(u, t, 2, :ArcLen, :Average; extrapolate = true)
@test A(-1.0) == u[1]
Expand All @@ -633,6 +639,12 @@ end
@test [A(t[1]), A(t[end])] [u[1], u[end]]
test_cached_index(A)

@test_throws ErrorException("BSplineApprox needs at least d + 1, i.e. 3 control points.") BSplineApprox(
u, t, 2, 2, :Uniform, :Uniform)
@test_throws ErrorException("BSplineApprox needs at least d + 1, i.e. 4 control points.") BSplineApprox(
u, t, 3, 3, :ArcLen, :Average)
@test_nowarn BSplineApprox(u, t, 2, 3, :Uniform, :Uniform)

# Test extrapolation
A = BSplineApprox(u, t, 2, 4, :Uniform, :Uniform; extrapolate = true)
@test A(-1.0) == u[1]
Expand Down

0 comments on commit 19b1db9

Please sign in to comment.