Skip to content

Commit

Permalink
update tests for KnotVector
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium committed Nov 11, 2023
1 parent 1795d7f commit c7918bf
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/test_KnotVector.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@testset "KnotVector" begin
k1 = KnotVector([1,2,3])
k2 = KnotVector([1,2,2,3])
k3 = KnotVector([2,4,5])
@testset "constructor" begin
k1 = KnotVector([1,2,3])
k2 = KnotVector([1,2,2,3])
@test k1 isa KnotVector{Int64}
@test k1 == KnotVector(1:3)::KnotVector{Int}
@test k1 == KnotVector([1,3,2])::KnotVector{Int64}
Expand Down Expand Up @@ -64,6 +63,8 @@
end

@testset "zeros" begin
k1 = KnotVector([1,2,3])

@test KnotVector(Float64[]) == zero(KnotVector)
@test KnotVector(Float64[]) == 0*k1 == k1*0 == zero(k1)
@test KnotVector(Float64[]) == EmptyKnotVector()
Expand Down Expand Up @@ -98,6 +99,9 @@
end

@testset "iterator" begin
k1 = KnotVector([1,2,3])
k2 = KnotVector([1,2,2,3])
k3 = KnotVector([2,4,5])
for t in k1
@test t in k2
end
Expand All @@ -110,6 +114,10 @@
end

@testset "addition, multiply" begin
k1 = KnotVector([1,2,3])
k2 = KnotVector([1,2,2,3])
k3 = KnotVector([2,4,5])

@test KnotVector([-1,2,3]) + 2 * KnotVector([2,5]) == KnotVector([-1,2,2,2,3,5,5])
@test KnotVector([-1,2,3]) + KnotVector([2,5]) * 2 == KnotVector([-1,2,2,2,3,5,5])
@test k1 + k3 == KnotVector([1,2,2,3,4,5])
Expand Down Expand Up @@ -151,6 +159,9 @@
end

@testset "unique" begin
k1 = KnotVector([1,2,3])
k2 = KnotVector([1,2,2,3])

@test unique(k1) == k1
@test unique(k2) == k1
@test unique(EmptyKnotVector()) === EmptyKnotVector()
Expand Down

0 comments on commit c7918bf

Please sign in to comment.