mirror of
https://github.com/Cian-H/nanoconc.git
synced 2026-04-28 12:01:49 +01:00
First commit (yeah, its a mess)
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
using Test
|
||||
|
||||
if !@isdefined TestUtils
|
||||
include("testutils.jl")
|
||||
end
|
||||
if !@isdefined nanoconc
|
||||
include("../src/nanoconc.jl")
|
||||
end
|
||||
|
||||
@testset "miemfp" begin
|
||||
@testset "miemfp.bhmie" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.miemfp.bhmie,
|
||||
"test/data/Main.nanoconc.miemfp.bhmie.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "miemfp.mfp" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.miemfp.mfp,
|
||||
"test/data/Main.nanoconc.miemfp.mfp.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "miemfp.qbare" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.miemfp.qbare,
|
||||
"test/data/Main.nanoconc.miemfp.qbare.ser"
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,24 @@
|
||||
using Test
|
||||
|
||||
if !@isdefined TestUtils
|
||||
include("testutils.jl")
|
||||
end
|
||||
if !@isdefined nanoconc
|
||||
include("../src/nanoconc.jl")
|
||||
end
|
||||
|
||||
@testset "nanoconc" begin
|
||||
@testset "qpredict" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.qpredict,
|
||||
"test/data/Main.nanoconc.qpredict.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "nanoconc" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.abspredict,
|
||||
"test/data/Main.nanoconc.abspredict.ser"
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
using Test
|
||||
|
||||
if !@isdefined TestUtils
|
||||
include("testutils.jl")
|
||||
end
|
||||
if !@isdefined nanoconc
|
||||
include("../src/nanoconc.jl")
|
||||
end
|
||||
|
||||
@testset "quantumcalc" begin
|
||||
@testset "quantumcalc.attencoeff" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.quantumcalc.attencoeff,
|
||||
"test/data/Main.nanoconc.quantumcalc.attencoeff.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "quantumcalc.attentoabs" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.quantumcalc.attentoabs,
|
||||
"test/data/Main.nanoconc.quantumcalc.attentoabs.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "quantumcalc.numtomol" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.quantumcalc.numtomol,
|
||||
"test/data/Main.nanoconc.quantumcalc.numtomol.ser"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "quantumcalc.predictabs" begin
|
||||
TestUtils.test_from_serialized(
|
||||
nanoconc.quantumcalc.predictabs,
|
||||
"test/data/Main.nanoconc.quantumcalc.predictabs.ser"
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
using Test
|
||||
|
||||
include("testutils.jl")
|
||||
include("../src/nanoconc.jl")
|
||||
|
||||
include("nanoconc_tests.jl")
|
||||
include("miemfp_tests.jl")
|
||||
include("quantumcalc_tests.jl")
|
||||
@@ -0,0 +1,25 @@
|
||||
module TestUtils
|
||||
using Serialization
|
||||
|
||||
using Test
|
||||
|
||||
function fieldvalues(obj)
|
||||
[getfield(obj, f) for f in fieldnames(typeof(obj))]
|
||||
end
|
||||
|
||||
deep_compare(a, b; rtol::Real=sqrt(eps()), atol::Real=0.) = a == b # base case: use ==
|
||||
deep_compare(a::Union{AbstractFloat, Complex}, b::Union{AbstractFloat, Complex}; rtol::Real=sqrt(eps()), atol::Real=0.) = isapprox(a, b) # for floats, use isapprox
|
||||
deep_compare(a::Union{Array{AbstractFloat}, Array{Complex}}, b::Union{Array{AbstractFloat}, Array{Complex}}; rtol::Real=sqrt(eps()), atol::Real=0.) = isapprox(a, b) # for arrays of floats, use isapprox element-wise
|
||||
deep_compare(a::AbstractArray, b::AbstractArray; rtol::Real=sqrt(eps()), atol::Real=0.) = all(deep_compare.(a, b; rtol, atol)) # for arrays of other types, recurse
|
||||
deep_compare(a::Tuple, b::Tuple; rtol::Real=sqrt(eps()), atol::Real=0.) = all(deep_compare.(a, b; rtol, atol)) # for tuples, recurse
|
||||
deep_compare(a::T, b::T; rtol::Real=sqrt(eps()), atol::Real=0.) where {T <: Any} = deep_compare(fieldvalues(a), fieldvalues(b); rtol, atol) # for composite types, recurse
|
||||
|
||||
function test_from_serialized(fn::Function, filename::String)
|
||||
argskwargs, out = open(filename, "r") do f
|
||||
deserialize(f)
|
||||
end
|
||||
|
||||
@test deep_compare([fn(a...; kw...) for (a, kw) in argskwargs], out)
|
||||
end
|
||||
|
||||
end # module TestUtils
|
||||
Reference in New Issue
Block a user