Add execution test
This commit is contained in:
@ -8,6 +8,7 @@ using Test
|
||||
include("unit_tests_properties.jl")
|
||||
include("node_reduction.jl")
|
||||
include("unit_tests_graph.jl")
|
||||
include("unit_tests_execution.jl")
|
||||
|
||||
include("known_graphs.jl")
|
||||
end
|
||||
|
31
test/unit_tests_execution.jl
Normal file
31
test/unit_tests_execution.jl
Normal file
@ -0,0 +1,31 @@
|
||||
import MetagraphOptimization.A
|
||||
import MetagraphOptimization.B
|
||||
import MetagraphOptimization.ParticleType
|
||||
|
||||
@testset "Unit Tests Graph" begin
|
||||
particles = Dict{ParticleType, Vector{Particle}}(
|
||||
(
|
||||
A => [
|
||||
Particle(0.823648, 0.0, 0.0, 0.823648, A),
|
||||
Particle(0.823648, -0.835061, -0.474802, 0.277915, A),
|
||||
]
|
||||
),
|
||||
(
|
||||
B => [
|
||||
Particle(0.823648, 0.0, 0.0, -0.823648, B),
|
||||
Particle(0.823648, 0.835061, 0.474802, -0.277915, B),
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
expected_result = 5.5320567694746876e-5
|
||||
|
||||
for _ in 1:10 # test in a loop because graph layout should not change the result
|
||||
graph = parse_abc(joinpath(@__DIR__, "..", "input", "AB->AB.txt"))
|
||||
@test isapprox(execute(graph, particles), expected_result; rtol = 0.001)
|
||||
|
||||
code = MetagraphOptimization.gen_code(graph)
|
||||
@test isapprox(execute(code, particles), expected_result; rtol = 0.001)
|
||||
end
|
||||
end
|
||||
println("Execution Unit Tests Complete!")
|
Reference in New Issue
Block a user