-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move tests to TestItems. Add compat * Tag new version. Update CI
- Loading branch information
Showing
9 changed files
with
154 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,3 @@ | ||
using ConstraintCommons | ||
using ConstraintDomains | ||
using Dictionaries | ||
using Intervals | ||
using Test | ||
using TestItemRunner | ||
|
||
@testset "ConstraintDomains.jl" begin | ||
@testset "EmptyDomain" begin | ||
ed = domain() | ||
@test domain_size(ed) == 0 == length(ed) | ||
@test isempty(ed) | ||
@test π ∉ ed | ||
end | ||
|
||
@testset "DiscreteDomain" begin | ||
d1 = domain([4,3,2,1]) | ||
d2 = domain(1) | ||
foreach(i -> add!(d2, i), 2:4) | ||
domains = Dictionary(1:2, [d1, d2]) | ||
|
||
for d in domains | ||
# constructors and ∈ | ||
for x in [1,2,3,4] | ||
@test x ∈ d | ||
end | ||
# length | ||
@test length(d) == 4 | ||
# draw and ∈ | ||
@test rand(d) ∈ d | ||
# add! | ||
add!(d, 5) | ||
@test 5 ∈ d | ||
# delete! | ||
delete!(d, 5) | ||
@test 5 ∉ d | ||
@test domain_size(d) == 3 | ||
end | ||
end | ||
|
||
@testset "ContinuousDomain" begin | ||
d1 = domain(1.0..3.15) | ||
d2 = domain(Interval{Open, Open}(-42.42, 5.0)) | ||
# d3 = domain([d1, d2]) | ||
domains = Dictionary(1:2, [d1, d2]) | ||
|
||
for d in domains | ||
for x in [1, 2.3, π] | ||
@test x ∈ d | ||
end | ||
for x in [5.1, π^π, Inf] | ||
@test x ∉ d | ||
end | ||
@test rand(d) ∈ d | ||
@test rand(d, 1) ∈ d | ||
@test domain_size(d) > 0.0 | ||
end | ||
|
||
end | ||
|
||
@testset "RangeDomain" begin | ||
d1 = domain(1:5) | ||
d2 = domain(1:.5:5) | ||
domains = Dictionary(1:2, [d1, d2]) | ||
|
||
for d in domains | ||
for x in [1, 2, 3, 4, 5] | ||
@test x ∈ d | ||
end | ||
for x in [42] | ||
@test x ∉ d | ||
end | ||
@test rand(d) ∈ d | ||
end | ||
|
||
end | ||
|
||
@testset "Exploration" begin | ||
domains = [domain([1,2,3,4]) for i in 1:4] | ||
X, X̅ = explore(domains, allunique) | ||
@test length(X) == factorial(4) | ||
@test length(X̅) == 4^4 - factorial(4) | ||
end | ||
end | ||
@run_package_tests |