Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ OrdinaryDiffEqSDIRK = "1, 2"
ProgressMeter = "1.2"
PyCall = "1.90"
Requires = "0.5, 1.0"
SafeTestsets = "0.1, 1"
SpecialFunctions = "0.8, 0.9, 1.2, 2"
julia = "1.6"

Expand All @@ -25,7 +26,8 @@ ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ADTypes", "ExplicitImports", "Test", "OrdinaryDiffEq", "OrdinaryDiffEqSDIRK"]
test = ["ADTypes", "ExplicitImports", "Test", "OrdinaryDiffEq", "OrdinaryDiffEqSDIRK", "SafeTestsets"]
14 changes: 14 additions & 0 deletions test/assign_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using FEniCS
using Test

@testset "assign" begin
mesh = UnitIntervalMesh(10)
V = FunctionSpace(mesh, "P", 1)
u = interpolate(Expression("x[0]", degree = 1), V)
arr1 = get_array(u)
arr2 = randn(size(arr1))
assign(u, arr2)
@test get_array(u) == arr2
assign(u, arr1)
@test get_array(u) == arr1
end
6 changes: 6 additions & 0 deletions test/creation_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using FEniCS
using Test

@test include("test_create.jl")
@test include("test_pycreate.jl")
@test include("test_jfem.jl")
19 changes: 19 additions & 0 deletions test/examples_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using FEniCS
using Test

FEniCS.set_log_level(FEniCS.WARNING)

examples_dir = joinpath(@__DIR__, "..", "examples")
@assert ispath(examples_dir)
example_filenames = readdir(examples_dir)
@assert "tutorial1.jl" in example_filenames

@testset "Example $(filename)" for filename in example_filenames
path = joinpath(examples_dir, filename)
@test (include(path); true)
# Test that PyCall is not used in the example.
# Use of PyCall indicates, that we did not wrap enough
# functionality
s = read(path, String)
@test !occursin("PyCall", s)
end
14 changes: 14 additions & 0 deletions test/interface_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using FEniCS
using Test

#tests relating to interface.jl file
@testset "Interface" begin
global mesh = UnitSquareMesh(2, 2)
dbc(x, y) = 1
global u = feMesh(mesh, dbc)
@test (u.n_nodes == 9)
@test (u.n_elements == 8)
@test (u.n_internal_nodes == 1)
@test (u.n_boundary_nodes == 8)
@test (u.node_vals == [1, 1, 1, 1, 0, 1, 1, 1, 1])
end
56 changes: 12 additions & 44 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,53 +1,21 @@
using FEniCS
using Test
using SafeTestsets

FEniCS.set_log_level(FEniCS.WARNING)

@testset "Explicit Imports" begin
@safetestset "Explicit Imports" begin
include("explicit_imports.jl")
end

examples_dir = joinpath(@__DIR__, "..", "examples")
@assert ispath(examples_dir)
example_filenames = readdir(examples_dir)
@assert "tutorial1.jl" in example_filenames

@testset "Example $(filename)" for filename in example_filenames
path = joinpath(examples_dir, filename)
@test (include(path); true)
# Test that PyCall is not used in the example.
# Use of PyCall indicates, that we did not wrap enough
# functionality
s = read(path, String)
@test !occursin("PyCall", s)
@safetestset "Examples" begin
include("examples_tests.jl")
end

@testset "Creation" begin
@test include("test_create.jl")
@test include("test_pycreate.jl")
@test include("test_jfem.jl")
end;
@safetestset "Creation" begin
include("creation_tests.jl")
end

@testset "assign" begin
mesh = UnitIntervalMesh(10)
V = FunctionSpace(mesh, "P", 1)
u = interpolate(Expression("x[0]", degree = 1), V)
arr1 = get_array(u)
arr2 = randn(size(arr1))
assign(u, arr2)
@test get_array(u) == arr2
assign(u, arr1)
@test get_array(u) == arr1
@safetestset "assign" begin
include("assign_tests.jl")
end

#tests relating to interface.jl file
@testset "Interface" begin
global mesh = UnitSquareMesh(2, 2)
dbc(x, y) = 1
global u = feMesh(mesh, dbc)
@test (u.n_nodes == 9)
@test (u.n_elements == 8)
@test (u.n_internal_nodes == 1)
@test (u.n_boundary_nodes == 8)
@test (u.node_vals == [1, 1, 1, 1, 0, 1, 1, 1, 1])
end;
@safetestset "Interface" begin
include("interface_tests.jl")
end