TugJulia/julia/TUG/test/TestGrid.jl
nebmit 01b2247344
test: added package unit tests
Created unit tests for Boundary, Grid, Simulation and Dynamic Simulation.

[skip ci]
2023-12-04 09:20:19 +01:00

92 lines
3.0 KiB
Julia

@testset "Grid.jl" begin
@testset "1D-Grid" begin
grid = TUG.Grid{Float64}(20, zeros(1, 20))
@test TUG.getCols(grid) == 20
@test TUG.getRows(grid) == 1
@test TUG.getDim(grid) == 1
concentrations = TUG.getConcentrations(grid)
@test size(concentrations) == (1, 20)
@test all(concentrations .== 0)
alphaX = TUG.getAlphaX(grid)
@test size(alphaX) == (1, 20)
@test all(alphaX .== 0)
@test_throws ErrorException TUG.getAlphaY(grid)
alphaX_t = TUG.getAlphaX_t(grid)
@test size(alphaX_t) == (20, 1)
@test all(alphaX_t .== 0)
@test_throws ErrorException TUG.getAlphaY_t(grid)
end
@testset "2D-Grid" begin
grid = TUG.Grid{Float64}(25, 20, zeros(25, 20), ones(25, 20))
@test TUG.getCols(grid) == 20
@test TUG.getRows(grid) == 25
@test TUG.getDim(grid) == 2
concentrations = TUG.getConcentrations(grid)
@test size(concentrations) == (25, 20)
@test all(concentrations .== 0)
alphaX = TUG.getAlphaX(grid)
@test size(alphaX) == (25, 20)
@test all(alphaX .== 0)
alphaY = TUG.getAlphaY(grid)
@test size(alphaY) == (25, 20)
@test all(alphaY .== 1)
alphaX_t = TUG.getAlphaX_t(grid)
@test size(alphaX_t) == (20, 25)
@test all(alphaX_t .== 0)
alphaY_t = TUG.getAlphaY_t(grid)
@test size(alphaY_t) == (20, 25)
@test all(alphaY_t .== 1)
end
@testset "Clone" begin
grid = TUG.Grid{Float64}(20, zeros(1, 20))
gridClone = TUG.clone(grid)
@test TUG.getCols(gridClone) == 20
@test TUG.getRows(gridClone) == 1
@test TUG.getDim(gridClone) == 1
concentrations = TUG.getConcentrations(gridClone)
@test size(concentrations) == (1, 20)
@test all(concentrations .== 0)
alphaX = TUG.getAlphaX(gridClone)
@test size(alphaX) == (1, 20)
@test all(alphaX .== 0)
@test_throws ErrorException TUG.getAlphaY(gridClone)
alphaX_t = TUG.getAlphaX_t(gridClone)
@test size(alphaX_t) == (20, 1)
@test all(alphaX_t .== 0)
@test_throws ErrorException TUG.getAlphaY_t(gridClone)
grid = TUG.Grid{Float64}(25, 20, zeros(25, 20), ones(25, 20))
gridClone = TUG.clone(grid)
@test TUG.getCols(gridClone) == 20
@test TUG.getRows(gridClone) == 25
@test TUG.getDim(gridClone) == 2
concentrations = TUG.getConcentrations(gridClone)
@test size(concentrations) == (25, 20)
@test all(concentrations .== 0)
alphaX = TUG.getAlphaX(gridClone)
@test size(alphaX) == (25, 20)
@test all(alphaX .== 0)
alphaY = TUG.getAlphaY(gridClone)
@test size(alphaY) == (25, 20)
@test all(alphaY .== 1)
alphaX_t = TUG.getAlphaX_t(gridClone)
@test size(alphaX_t) == (20, 25)
@test all(alphaX_t .== 0)
alphaY_t = TUG.getAlphaY_t(gridClone)
@test size(alphaY_t) == (20, 25)
@test all(alphaY_t .== 1)
end
end