Skip to content
Snippets Groups Projects
Commit b1687958 authored by florian's avatar florian
Browse files

ENH: Replace dummy function by libcaosdb version retrieval

parent 01bcdd20
No related branches found
No related tags found
1 merge request!1DRAFT: ENH: Include libcaosdb and a minimal wrapper
Pipeline #9992 failed
......@@ -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;});
}
# 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
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())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment