From 9dc2a4480b65b77637b4384e9707f901da706c6e Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 23 Jan 2019 20:21:18 +0100 Subject: [PATCH] add tests --- test/unit_Intersection.jl | 7 +++++++ test/unit_Polyhedron.jl | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/unit_Intersection.jl b/test/unit_Intersection.jl index ba9528f6c8..f1b6453ac2 100644 --- a/test/unit_Intersection.jl +++ b/test/unit_Intersection.jl @@ -27,6 +27,13 @@ for N in [Float64, Rational{Int}, Float32] @test isempty_known(I) @test !isempty(I) + # constraints_list for polytopic intersection + @test ispermutation(constraints_list(I), + [HalfSpace{Float64}(N[1, 0], N(2)), + HalfSpace{Float64}(N[0, 1], N(2)), + HalfSpace{Float64}(N[-1, 0], N(0)), + HalfSpace{Float64}(N[0, -1], N(0))]) + # ================= # IntersectionArray # ================= diff --git a/test/unit_Polyhedron.jl b/test/unit_Polyhedron.jl index ef7b221fc6..98cf3b603e 100644 --- a/test/unit_Polyhedron.jl +++ b/test/unit_Polyhedron.jl @@ -28,6 +28,13 @@ for N in [Float64, Rational{Int}, Float32] addconstraint!(p, c4) addconstraint!(p, c2) + # tosimplehrep for other polytopic types + A, b = tosimplehrep(BallInf(N[0], N(2))) + @test (A == hcat(N[1; -1]) || A == hcat(N[-1; 1])) && b == N[2, 2] + # tosimplehrep from list of constraints + A, b = tosimplehrep([HalfSpace(N[1], N(2)), HalfSpace(N[-1], N(2))]) + @test (A == hcat(N[1; -1]) || A == hcat(N[-1; 1])) && b == N[2, 2] + # support vector d = N[1, 0] @test σ(d, p) == N[4, 2] @@ -154,6 +161,12 @@ if test_suite_polyhedra Ar, br = tosimplehrep(p1) @test Ar == A[1:2, :] && br == b[1:2] + # removing redundant constraints from a list of constraints + constraints = [HalfSpace(N[1], N(1)), HalfSpace(N[1], N(0))] + constraints2 = remove_redundant_constraints(constraints) + remove_redundant_constraints!(constraints) + @test ispermutation(constraints, constraints2) + # checking for empty intersection (also test symmetric calls) P = convert(HPolytope, BallInf(zeros(N, 2), N(1))) Q = convert(HPolytope, BallInf(ones(N, 2), N(1)))