Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jan 23, 2019
1 parent df39fc7 commit 9dc2a44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/unit_Intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
# =================
Expand Down
13 changes: 13 additions & 0 deletions test/unit_Polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 9dc2a44

Please sign in to comment.