|
1 | 1 | using MAT, Test, Dates |
| 2 | +using SparseArrays, LinearAlgebra |
2 | 3 |
|
3 | 4 | tmpfile = string(tempname(), ".mat") |
4 | 5 |
|
@@ -150,12 +151,33 @@ test_write(Dict("reshape_arr"=>reshape([1 2 3;4 5 6;7 8 9]',1,9))) |
150 | 151 | test_write(Dict("adjoint_arr"=>Any[1 2 3;4 5 6;7 8 9]')) |
151 | 152 | test_write(Dict("reshape_arr"=>reshape(Any[1 2 3;4 5 6;7 8 9]',1,9))) |
152 | 153 |
|
153 | | -# named tuple |
154 | | -nt = (x = 5, y = Any[6, "string"]) |
155 | | -matwrite(tmpfile, Dict("nt" => nt)) |
156 | | -nt_read = matread(tmpfile)["nt"] |
157 | | -@test nt_read["x"] == 5 |
158 | | -@test nt_read["y"] == nt.y |
| 154 | +@testset "named tuple" begin |
| 155 | + nt = (x = 5, y = Any[6, "string"]) |
| 156 | + matwrite(tmpfile, Dict("nt" => nt)) |
| 157 | + nt_read = matread(tmpfile)["nt"] |
| 158 | + @test nt_read["x"] == 5 |
| 159 | + @test nt_read["y"] == nt.y |
| 160 | +end |
| 161 | + |
| 162 | +@testset "tuple" begin |
| 163 | + # NTuple{T} |
| 164 | + t = (5, 6) |
| 165 | + matwrite(tmpfile, Dict("t" => (5, 6))) |
| 166 | + r = matread(tmpfile)["t"] |
| 167 | + @test r == [x for x in t] |
| 168 | + |
| 169 | + # otherwise cell array |
| 170 | + t = (5, "string") |
| 171 | + matwrite(tmpfile, Dict("t" => t)) |
| 172 | + r = matread(tmpfile)["t"] |
| 173 | + @test r == [x for x in t] |
| 174 | +end |
| 175 | + |
| 176 | +@testset "symbol" begin |
| 177 | + matwrite(tmpfile, Dict("s" => :symbol)) |
| 178 | + r = matread(tmpfile)["s"] |
| 179 | + @test r == "symbol" |
| 180 | +end |
159 | 181 |
|
160 | 182 | # test nested struct array - interface via Dict array |
161 | 183 | @testset "MatlabStructArray writing" begin |
|
0 commit comments