/
test_utilities.jl
57 lines (50 loc) · 1.37 KB
/
test_utilities.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@testset "Utilities" begin
@testset "ConicObj" begin
c = ConicObj()
z = UInt64(0)
@test !haskey(c, z)
c[z] = (1, 1)
@test c[z] == (1, 1)
x = UInt64[]
for (k, v) in c
push!(x, k)
end
@test x == collect(keys(c))
d = copy(c)
@test d !== c
end
@testset "length and size" begin
x = Variable(2,3)
@test length(x) == 6
@test size(x) == (2, 3)
@test size(x, 1) == 2
@test size(x, 2) == 3
x = Variable(3)
@test length(x) == 3
@test size(x) == (3, 1)
x = Variable()
@test length(x) == 1
@test size(x) == (1, 1)
end
@testset "lastindex and axes" begin
x = Variable(2, 3)
@test axes(x) == (Base.OneTo(2), Base.OneTo(3))
@test axes(x, 1) == Base.OneTo(2)
@test lastindex(x) == 6
@test lastindex(x, 2) == 3
y = x[:,end]
@test y isa AbstractExpr
@test size(y) == (2, 1)
end
@testset "Parametric constants" begin
z = Constant([1.0 0.0im; 0.0 1.0])
@test z isa Constant{Matrix{Complex{Float64}}}
end
# returns [21]; not sure why
# context("iteration") do
# x = Variable(2,3)
# s = sum([xi for xi in x])
# x.value = [1 2 3; 4 5 6]
# @fact evaluate(s) --> 21
# end
end