Skip to content

Commit

Permalink
move from FactCheck to Base.Test
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 3, 2016
1 parent 93a4268 commit db41ea3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 46 deletions.
1 change: 0 additions & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
FactCheck
Combinatorics
14 changes: 7 additions & 7 deletions test/board.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
facts("Low-level board tests") do
@testset "Low-level board tests" begin
A1 = -eye(Int, 9) # x >= 0
b1 = zeros(Int, 9)
A2 = eye(Int, 9) # x <= 1
Expand Down Expand Up @@ -35,19 +35,19 @@ facts("Low-level board tests") do
ok = true
end
end
@fact ok --> true
@test ok

cutA = ones(Int, 1, 9)
cutb = 6
Acut = [cutA; A]
bcut = [cutb; b]
inecut = Polyhedra.SimpleHRepresentation(Acut, bcut)
(isredundant, certificate) = redundant(inecut, 1)
@fact isredundant --> false
@fact Array{Rational{Int}}(certificate) --> target
@test !isredundant
@test Array{Rational{Int}}(certificate) == target
redundantrows(inecut)
@fact IntSet() --> redundantrows(inecut)
@test IntSet() == redundantrows(inecut)
(issredundant, scertificate) = sredundant(inecut, 1)
@fact issredundant --> false
@fact Array{Rational{Int}}(scertificate) --> target
@test !issredundant
@test Array{Rational{Int}}(scertificate) == target
end
30 changes: 15 additions & 15 deletions test/permutahedron.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
facts("Low-level permutahedron tests") do
@testset "Low-level permutahedron tests" begin
A = [1 1 1; 1 0 0; 0 1 0; 0 0 1; -1 0 0; 0 -1 0; 0 0 -1]
b = [6, 3, 3, 3, -1, -1, -1]
ls = IntSet([1])
V = [2 3 1; 1 3 2; 3 1 2; 3 2 1; 2 1 3; 1 2 3]
ine = SimpleHRepresentation(A, b, ls)
#@fact isempty(ine) --> false
#@test !isempty(ine)
inef = SimpleHRepresentation(Array{Float64}(A), Array{Float64}(b), ls)
#@fact isempty(inef) --> false
#@test !isempty(inef)
poly = CDDPolyhedra(ine)
polyf = CDDPolyhedra(inef)
ineoutm = copyinequalities(poly)
ineoutmf = copyinequalities(polyf)
extm = copygenerators(poly)
extmf = copygenerators(polyf)
@fact string(ineoutm) --> "H-representation
@test string(ineoutm) == "H-representation
linearity 1 1
begin
7 4 rational
Expand All @@ -25,7 +25,7 @@ begin
-1//1 0//1 1//1 0//1
-1//1 0//1 0//1 1//1
end"
@fact string(ineoutmf) --> "H-representation
@test string(ineoutmf) == "H-representation
linearity 1 1
begin
7 4 real
Expand All @@ -37,7 +37,7 @@ begin
-1.0 -0.0 1.0 -0.0
-1.0 -0.0 -0.0 1.0
end"
@fact string(extm) --> "V-representation
@test string(extm) == "V-representation
begin
6 4 rational
1//1 2//1 3//1 1//1
Expand All @@ -47,7 +47,7 @@ begin
1//1 2//1 1//1 3//1
1//1 1//1 2//1 3//1
end"
@fact string(extmf) --> "V-representation
@test string(extmf) == "V-representation
begin
6 4 real
1.0 2.0 3.0 0.9999999999999998
Expand Down Expand Up @@ -100,14 +100,14 @@ end"
canonicalize!(inelift0f)
inelift0d = SimpleHRepresentation{3,Int}(inelift0)
inelift0df = SimpleHRepresentation{3,Int}(inelift0f)
@fact inelift0d.linset --> IntSet(1)
@fact length(inelift0d.b) --> 7
@fact inelift0d.b[1] / sign(inelift0d.b[1]) --> 6
@fact vec(Array{Int}(inelift0d.A[1,:] / sign(inelift0d.b[1]))) --> [1; 1; 1] # Array{Int} cast and vec are for julia 0.4
@fact inelift0df.linset --> IntSet(1)
@fact length(inelift0df.b) --> 7
@fact inelift0df.b[1] / sign(inelift0df.b[1]) --> 6
@fact vec(Array{Int}(inelift0df.A[1,:] / sign(inelift0df.b[1]))) --> [1; 1; 1] # Array{Int} cast and vec are for julia 0.4
@test inelift0d.linset == IntSet(1)
@test length(inelift0d.b) == 7
@test inelift0d.b[1] / sign(inelift0d.b[1]) == 6
@test vec(Array{Int}(inelift0d.A[1,:] / sign(inelift0d.b[1]))) == [1; 1; 1] # Array{Int} cast and vec are for julia 0.4
@test inelift0df.linset == IntSet(1)
@test length(inelift0df.b) == 7
@test inelift0df.b[1] / sign(inelift0df.b[1]) == 6
@test vec(Array{Int}(inelift0df.A[1,:] / sign(inelift0df.b[1]))) == [1; 1; 1] # Array{Int} cast and vec are for julia 0.4
polylift = CDDPolyhedra(inelift0)
polyliftf = CDDPolyhedra(inelift0f)
extunlift = SimpleVRepresentation{3,Int}(copygenerators(polylift))
Expand Down
5 changes: 3 additions & 2 deletions test/polyhedron.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const polyhedra_test = joinpath(Pkg.dir("Polyhedra"), "test")

include(joinpath(polyhedra_test, "alltests.jl"))
alltests(CDDLibrary(:float))
alltests(CDDLibrary(:exact))
@testset "Polyhedra tests" for arith in [:float, :exact]
runtests(CDDLibrary(arith))
end
4 changes: 1 addition & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using CDDLib
using Polyhedra
using FactCheck
using Base.Test

include("simplex.jl")
include("permutahedron.jl")
include("board.jl")
#include("mathprogbase.jl")
include("polyhedron.jl")

FactCheck.exitstatus()
36 changes: 18 additions & 18 deletions test/simplex.jl
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
function inequality_simpletest(ine::SimpleHRepresentation, A, b, linset)
# @show ine
# @show SimpleHRepresentation(A, b, linset)
# @fact size(A) --> size(ine.A)
# @fact length(b) --> length(ine.b)
# @test size(A) == size(ine.A)
# @test length(b) == length(ine.b)
# for i in 1:length(b)
# @assert (i in linset) --> (i in ine.linset)
# @assert (i in linset) == (i in ine.linset)
# if i in linset
# if b[i] < 0 $ ine.b[i] < 0
# @fact -A[i,:] --> ine.A[i,:]
# @fact -b[i] --> ine.b[i]
# @test -A[i,:] == ine.A[i,:]
# @test -b[i] == ine.b[i]
# else
# @fact A[i,:] --> ine.A[i,:]
# @fact b[i] --> ine.b[i]
# @test A[i,:] == ine.A[i,:]
# @test b[i] == ine.b[i]
# end
# else
# @fact A[i,:] --> ine.A[i,:]
# @fact b[i] --> ine.b[i]
# @test A[i,:] == ine.A[i,:]
# @test b[i] == ine.b[i]
# end
# end
@fact A --> ine.A
@fact b --> ine.b
@fact linset --> ine.linset
@test A == ine.A
@test b == ine.b
@test linset == ine.linset
end
inequality_simpletest(ine::HRepresentation, A, b, linset) = inequality_simpletest(SimpleHRepresentation(ine), A, b, linset)
function generator_simpletest(ext::SimpleVRepresentation, V, R = Matrix{eltype(V)}(0, size(V, 2)))
@fact sortrows(V) --> sortrows(ext.V)
@fact sortrows(R) --> sortrows(ext.R)
@test sortrows(V) == sortrows(ext.V)
@test sortrows(R) == sortrows(ext.R)
end
generator_simpletest(ext::VRepresentation, V, R = Matrix{eltype(V)}(0, size(V, 2))) = generator_simpletest(SimpleVRepresentation(ext), V, R)

facts("Low-level simplex tests") do
@testset "Low-level simplex tests" begin
A = [1 1; -1 0; 0 -1]
b = [1, 0, 0]
ls = IntSet([1])
V = [0 1; 1 0]

ine = SimpleHRepresentation(A, b, ls)
#@fact isempty(ine) --> false
#@test !isempty(ine)
inef = SimpleHRepresentation(Array{Float64}(A), Array{Float64}(b), ls)
#@fact isempty(inef) --> false
#@test !isempty(inef)
poly1 = CDDPolyhedra(ine)
poly1f = CDDPolyhedra(inef)
ineout1 = SimpleHRepresentation{2,Int}(copyinequalities(poly1 ))
Expand Down Expand Up @@ -67,7 +67,7 @@ facts("Low-level simplex tests") do
generator_simpletest(extout2f, V)

# x_1 cannot be 2
#@fact isempty(HRepresentation([A; 1 0], [b; 2], union(linset, IntSet([4])))) --> true
#@test isempty(HRepresentation([A; 1 0], [b; 2], union(linset, IntSet([4]))))

V0 = [0 0]
ext0 = SimpleVRepresentation(V0)
Expand Down

0 comments on commit db41ea3

Please sign in to comment.