Skip to content

Commit caeb4c4

Browse files
committed
add mutable test
1 parent 01f8690 commit caeb4c4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/sets.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
"""
2+
MutLessThan{T<:Real} <: MOI.AbstractScalarSet
3+
4+
A mutable `LessThan`-like set to test `copy` of indicator set
5+
"""
6+
mutable struct MutLessThan{T<:Real} <: MOI.AbstractScalarSet
7+
upper::T
8+
MutLessThan(v::T) where {T<:Real} = new{T}(v)
9+
end
10+
11+
Base.copy(mlt::MutLessThan) = MutLessThan(Base.copy(mlt.upper))
12+
113
@testset "Sets" begin
214
@testset "Copy" begin
315
@testset "for $S" for S in [MOI.SOS1, MOI.SOS2]
@@ -15,6 +27,12 @@
1527
@test s1 == s1_copy
1628
@test s2_copy isa MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}
1729
@test s2 == s2_copy
30+
s3 = MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO}(MutLessThan(4.0))
31+
s3_copy = copy(s3)
32+
@test s3.set.upper 4.0
33+
s3_copy.set.upper = 5.0
34+
@test s3.set.upper 4.0
35+
@test s3_copy.set.upper 5.0
1836
end
1937
end
2038
end

0 commit comments

Comments
 (0)