diff --git a/.gitignore b/.gitignore index e376671..6125730 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ # Results of C compilation *.o -lib.so \ No newline at end of file +lib.so + + +# Test artifacts +test/*/ \ No newline at end of file diff --git a/test/integration_tests.jl b/test/integration_tests.jl new file mode 100644 index 0000000..118d625 --- /dev/null +++ b/test/integration_tests.jl @@ -0,0 +1,23 @@ +@testset "Integration tests" begin + #= DEFAULT MODELS =# + gen = TaylorGenerator("sincos", "sincos.eqs", ".") + generate_dir(gen) + han = get_handler(gen, true) + + function flow(x, t, han) + y = similar(x) + ccall(han.symbols["flow"], Cint, (Cdouble, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cvoid}), + t, x, y, Ref(nothing) + ) + return y + end + + x = [1., 0.] + ts = LinRange(0., 2π, 101) + ys = map(t->flow(x, t, han), ts) + y1 = map(i->i[1], ys) + y2 = map(i->i[2], ys) + + @test y1 ≈ cos.(ts) + @test y2 ≈ -sin.(ts) +end diff --git a/test/sincos.eqs b/test/sincos.eqs new file mode 100644 index 0000000..b20da14 --- /dev/null +++ b/test/sincos.eqs @@ -0,0 +1,2 @@ +diff(x, t) = y; +diff(y, t) = -x; \ No newline at end of file