Skip to content

Commit

Permalink
Add more unit tests in test_curve.f90
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed May 17, 2024
1 parent 275e34c commit 375f91f
Showing 1 changed file with 67 additions and 6 deletions.
73 changes: 67 additions & 6 deletions test/test_curve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,93 @@ program test_curve
Xg = nurbs%get_Xg()
Xgb = bsp%get_Xg()

call nurbs%set([0.0_rk, 1.0_rk], 2, [-1, -1], Xc, Wc)
call bsp%set([0.0_rk, 1.0_rk], 2, [-1, -11], Xc)

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 01")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 02")

call nurbs%set(Xc, Wc)
call bsp%set(Xc)

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 03")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 04")

call nurbs%create(Xt = nurbs%get_Xt())
call bsp%create(Xt = nurbs%get_Xt())

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 05")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 06")

call ut%check(res=nurbs%get_Xc(), expected=Xc, tol=1e-5_rk, msg="test_curve: 07")
call ut%check(res=bsp%get_Xc(), expected=Xc, tol=1e-5_rk, msg="test_curve: 08")

call ut%check(res=nurbs%get_Xc(1), expected=Xc(1,:), tol=1e-5_rk, msg="test_curve: 09")
call ut%check(res=bsp%get_Xc(1), expected=Xc(1,:), tol=1e-5_rk, msg="test_curve: 10")

call ut%check(res=nurbs%get_Xc(1,1), expected=Xc(1,1), tol=1e-5_rk, msg="test_curve: 11")
call ut%check(res=bsp%get_Xc(1,1), expected=Xc(1,1), tol=1e-5_rk, msg="test_curve: 12")

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 13")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 14")

call ut%check(res=nurbs%get_Xg(1), expected=Xg(1,:), tol=1e-5_rk, msg="test_curve: 15")
call ut%check(res=bsp%get_Xg(1), expected=Xgb(1,:), tol=1e-5_rk, msg="test_curve: 16")

call ut%check(res=nurbs%get_Xg(1,1), expected=Xg(1,1), tol=1e-5_rk, msg="test_curve: 17")
call ut%check(res=bsp%get_Xg(1,1), expected=Xgb(1,1), tol=1e-5_rk, msg="test_curve: 18")

call ut%check(res=nurbs%get_Wc(), expected=Wc, tol=1e-5_rk, msg="test_curve: 19")

call ut%check(res=nurbs%get_Wc(1), expected=Wc(1), tol=1e-5_rk, msg="test_curve: 20")

call ut%check(res=nurbs%get_knot(), expected=knot, tol=1e-5_rk, msg="test_curve: 21")
call ut%check(res=bsp%get_knot(), expected=knot, tol=1e-5_rk, msg="test_curve: 22")

call ut%check(res=nurbs%get_knot(1), expected=knot(1), tol=1e-5_rk, msg="test_curve: 23")
call ut%check(res=bsp%get_knot(1), expected=knot(1), tol=1e-5_rk, msg="test_curve: 24")

call ut%check(res=nurbs%get_ng(), expected=size(Xg,1), msg="test_curve: 25")
call ut%check(res=bsp%get_ng(), expected=size(Xgb,1), msg="test_curve: 26")

call ut%check(res=nurbs%get_degree(), expected=2, msg="test_curve: 27")
call ut%check(res=bsp%get_degree(), expected=2, msg="test_curve: 28")

call ut%check(res=nurbs%get_multiplicity(), expected=[3,3], msg="test_curve: 29")
call ut%check(res=bsp%get_multiplicity(), expected=[3,3], msg="test_curve: 30")

call ut%check(res=nurbs%get_continuity(), expected=[-1,-1], msg="test_curve: 31")
call ut%check(res=bsp%get_continuity(), expected=[-1,-1], msg="test_curve: 32")

call ut%check(res=nurbs%get_nc(), expected=size(Xc,1), msg="test_curve: 33")
call ut%check(res=bsp%get_nc(), expected=size(Xc,1), msg="test_curve: 34")

call nurbs%insert_knots([0.25_rk, 0.75_rk], [2,1])
call bsp%insert_knots([0.25_rk, 0.75_rk], [2,1])

call nurbs%create()
call bsp%create()

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test 01")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test 02")
call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 35")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 36")

call nurbs%elevate_degree(2)
call bsp%elevate_degree(2)

call nurbs%create()
call bsp%create()

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test 03")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test 04")
call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 37")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 38")

call nurbs%remove_knots([0.25_rk, 0.75_rk], [2,1])
call bsp%remove_knots([0.25_rk, 0.75_rk], [2,1])

call nurbs%create()
call bsp%create()

call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test 05")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test 06")
call ut%check(res=nurbs%get_Xg(), expected=Xg, tol=1e-5_rk, msg="test_curve: 39")
call ut%check(res=bsp%get_Xg(), expected=Xgb, tol=1e-5_rk, msg="test_curve: 40")

call nurbs%finalize()
call bsp%finalize()
Expand Down

0 comments on commit 375f91f

Please sign in to comment.