diff --git a/jlcaosdb/jlcaosdb.cxx b/jlcaosdb/jlcaosdb.cxx index 15986d4fd18c894a2f662227dbc8a4591c90874c..37543e1606394cf697d69b0219d2c123dfe76231 100644 --- a/jlcaosdb/jlcaosdb.cxx +++ b/jlcaosdb/jlcaosdb.cxx @@ -22,9 +22,15 @@ */ #include <jlcxx/jlcxx.hpp> +#include "caosdb/authentication.h" #include "caosdb/connection.h" +#include "caosdb/constants.h" +#include "caosdb/exceptions.h" JLCXX_MODULE define_julia_module(jlcxx::Module& mod) { - + // Version info of libcaosdb against which this is built. + mod.method("get_libcaosdb_version_major", []() {return caosdb::LIBCAOSDB_VERSION_MAJOR;}); + mod.method("get_libcaosdb_version_minor", []() {return caosdb::LIBCAOSDB_VERSION_MINOR;}); + mod.method("get_libcaosdb_version_patch", []() {return caosdb::LIBCAOSDB_VERSION_PATCH;}); } diff --git a/src/CaosDB.jl b/src/CaosDB.jl index f17fb67a17e550235c24f5f78d19842832503b51..6b725fa842e452cc29794ff11dd5a56dc1826c28 100644 --- a/src/CaosDB.jl +++ b/src/CaosDB.jl @@ -1,21 +1,29 @@ +# Useful for development, TODO remove for production +__precompile__(false) + module CaosDB using CxxWrap # Adapt this path if you haven't compiled jlcaosdb to `caosdb-julialib/build` -@wrapmodule(joinpath(pwd(), "build/lib/libjlcaosdb")) +@wrapmodule(joinpath(@__DIR__, "../jlcaosdb/build/lib/libjlcaosdb")) function __init__() @initcxx end -export dummy_func - """ - dummy_func(x) + get_libcaosdb_version() -Returns double the number `x` plus `1`. +Returns the version string of libcaosdb with which this package has +been built. """ -dummy_func(x) = 2x + 1 +function get_libcaosdb_version() + major = get_libcaosdb_version_major() + minor = get_libcaosdb_version_minor() + patch = get_libcaosdb_version_patch() + + return "$major.$minor.$patch" +end end # module diff --git a/test/runtests.jl b/test/runtests.jl index 04b3c1aa41638318f2d745a4518717fc58efd7a9..11c94afe90d27586466fcc98c827dbe71df113a2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1 +1,10 @@ -println("Testing...") +using CaosDB +using Test + +# Test whether retrieving the libcaosdb version works as expected +@test CaosDB.get_libcaosdb_version() != Nothing +@test length(split(CaosDB.get_libcaosdb_version(), ".")) == 3 +@test split(CaosDB.get_libcaosdb_version(), ".")[1] == string(CaosDB.get_libcaosdb_version_major()) +@test split(CaosDB.get_libcaosdb_version(), ".")[2] == string(CaosDB.get_libcaosdb_version_minor()) +@test split(CaosDB.get_libcaosdb_version(), ".")[3] == string(CaosDB.get_libcaosdb_version_patch()) +