From 7f7c438dc0f04323c7551a64332adad2e76df84b Mon Sep 17 00:00:00 2001 From: Kevin-Mattheus-Moerman Date: Sun, 31 Mar 2024 20:27:16 +0100 Subject: [PATCH] Added testing for meshgroup #20 --- examples/demo_meshgroup.jl | 2 +- test/runtests.jl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/examples/demo_meshgroup.jl b/examples/demo_meshgroup.jl index 13d4701..14edb02 100644 --- a/examples/demo_meshgroup.jl +++ b/examples/demo_meshgroup.jl @@ -3,7 +3,7 @@ using GLMakie using GeometryBasics # Example geometry -testCase = 3 +testCase = 1 if testCase == 1 s=1.0 V=Vector{GeometryBasics.Point{3, Float64}}(undef,5) diff --git a/test/runtests.jl b/test/runtests.jl index bad280d..1c9d1a6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -34,6 +34,7 @@ end end end + @testset "gridpoints" verbose = true begin @testset "with 1 vector" begin @@ -1903,6 +1904,37 @@ end end +@testset "meshgroup" verbose = true begin + @testset "Single face" begin + # Single triangle + F = TriangleFace{Int64}[[1,2,3]] + V = Point3{Float64}[[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0]] + C = meshgroup(F) + @test C == [1] + + # Single quad + F = QuadFace{Int64}[[1,2,3,4]] + V = Point3{Float64}[[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0]] + C = meshgroup(F) + @test C == [1] + end + + @testset "Two separate faces" begin + # Two triangles + F = TriangleFace{Int64}[[1,2,3],[4,5,6]] + V = Point3{Float64}[[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0], + [0.0,0.0,1.0],[1.0,0.0,1.0],[1.0,1.0,1.0]] + C = meshgroup(F) + @test C == [1,2] + + # Two quads + F = QuadFace{Int64}[[1,2,3,4],[5,6,7,8]] + V = Point3{Float64}[[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0], + [0.0,0.0,1.0],[1.0,0.0,1.0],[1.0,1.0,1.0],[0.0,1.0,1.0]] + C = meshgroup(F) + @test C == [1,2] + end +end @testset "separate vertices" begin