diff --git a/CMakeLists.txt b/CMakeLists.txt
index de06696a4e01024992c5ffa8371e7bcef0060aa8..7d3cbe4cac0c13c2766fcff1e2ad0bcec0a01bdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,15 +55,27 @@ endif()
 
 
 #######################################################
-### Build utility library
+### Build utility library "maoxdb"
 #######################################################
 # The library will be called maoxdb until we find a better name.  The name is not very important
 # though, since the library is used only internally.
 
+# OCTINCLUDEDIR
 execute_process(COMMAND mkoctfile -p OCTINCLUDEDIR
     OUTPUT_VARIABLE OCTINCLUDEDIR
     )
 string(REGEX REPLACE "\n" "" OCTINCLUDEDIR "${OCTINCLUDEDIR}")
+# OCTLIBDIR
+execute_process(COMMAND mkoctfile -p OCTLIBDIR
+    OUTPUT_VARIABLE OCTLIBDIR
+    )
+string(REGEX REPLACE "\n" "" OCTLIBDIR "${OCTLIBDIR}")
+# OCTLIBS
+execute_process(COMMAND mkoctfile -p OCTAVE_LIBS
+    OUTPUT_VARIABLE OCTLIBS
+    )
+string(REGEX REPLACE "\n" "" OCTLIBS "${OCTLIBS}")
+string(REGEX REPLACE " " ";" OCTLIBS "${OCTLIBS}")
 
 set(MAOXDB_DIR "${PROJECT_SOURCE_DIR}/src/lib")
 add_library(maoxdb STATIC "${MAOXDB_DIR}/test.cpp" "${MAOXDB_DIR}/maoxdb.cpp")
@@ -161,4 +173,56 @@ else()
     message(STATUS "LINTING is OFF")
 endif()
 
+###############################################################################
+#                                    Tests                                    #
+###############################################################################
 
+option(TEST "Unit test with gtest" OFF)
+if(TEST)
+    enable_testing()
+    # append all the test cases here (file name without the ".cpp" suffix)
+    set(test_cases
+        test_utilities
+        )
+    # add special cmake functions for gtest
+    include(GoogleTest)
+    # `make testfiles` shall just build the tests, `make test` builds and runs the tests
+    add_custom_target(testfiles)
+    add_custom_target(test_detailed DEPENDS testfiles)
+    # loop over all test cases and add them to the test runner
+    list(LENGTH test_cases len_test_cases)
+    math(EXPR len_test_cases "${len_test_cases} - 1")
+    foreach (i RANGE "${len_test_cases}")
+        list(GET test_cases ${i} test_case_name)
+        # Use this instead, once cmake 3.14 is available everywhere.
+        # foreach (test_case_name "${test_cases}")
+        message(STATUS "test_case_name: ${test_case_name}")
+        add_executable(${test_case_name} EXCLUDE_FROM_ALL test/${test_case_name}.cpp)
+        add_custom_target("test_${test_case_name}" "${test_case_name}" DEPENDS "${test_case_name}")
+        add_dependencies(test_detailed "test_${test_case_name}")
+        # set(libcaosdb_TEST_SRC
+        #     "${CMAKE_CURRENT_SOURCE_DIR}/${test_case_name}.cpp ${libcaosdb_TEST_SRC}")
+        target_include_directories(${test_case_name} PUBLIC
+            ${OCTINCLUDEDIR}
+            ${MAOXDB_DIR})
+        target_link_libraries(${test_case_name} PUBLIC
+            maoxdb ${CONAN_LIBS_CAOSDB} ${CONAN_LIBS_GTEST} ${CONAN_LIBS_BOOST})
+        target_link_directories(${test_case_name} PUBLIC ${OCTLIBDIR})
+        target_link_options(${test_case_name} PUBLIC ${OCTLIBS})
+        if(_LINTING)
+            set_target_properties(${test_case_name}
+                PROPERTIES
+                CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY};${_CMAKE_CXX_CLANG_TIDY_TEST_CHECKS}"
+                CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}")
+        endif()
+        message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
+        gtest_discover_tests(${test_case_name}
+            WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+            TEST_LIST test_list
+            )
+        message(STATUS "tests for ${test_case_name}: ${test_list}")
+        add_dependencies(testfiles ${test_case_name})
+    endforeach ()
+else()
+    message(STATUS "TEST is OFF")
+endif(TEST)
diff --git a/test/Makefile b/test/Makefile
index df22f004530a83663c67a56cc7aa19be0c62aa4f..9b968c941d76ee46a3cd15470e3bcf57c40a0770 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -31,6 +31,7 @@ help:
 	@echo "    test - run unit tests."
 	@echo "    doc - create the documentation."
 
+
 ###############################################################################
 #                                    Tests                                    #
 ###############################################################################
@@ -43,5 +44,12 @@ test_octave:
 .PHONY: test_octave
 
 test_cpp:
-	
+	$(eval BUILD_DIR ::= $(shell mktemp -d build_XXXXXXXX))
+	cd $(BUILD_DIR)                                                \
+    && conan install ../.. -s "compiler.libcxx=libstdc++11"      \
+    && cmake -D TEST=On ../..                                    \
+    && make test || echo "Test(s) failed."; exit 1
+    # && make test || make test_detailed || echo "Test(s) failed." ; exit 1
+	# rm -r $(BUILD_DIR)
 .PHONY: test_cpp
+
diff --git a/test/test_utilities.cpp b/test/test_utilities.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bcbcfde33db06867cb7907fd897262cc158f2a16
--- /dev/null
+++ b/test/test_utilities.cpp
@@ -0,0 +1,37 @@
+/*
+ * This file is a part of the CaosDB Project.
+ *
+ * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+ * Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "maoxdb.hpp"
+#include "mex.h"
+// #include "mexproto.h"
+#include <gtest/gtest.h>
+
+namespace maoxdb {
+
+TEST(test_utilities, scalar_arrays) {
+  mxArray *uint64_scalar;
+  uint64_scalar = mxScalarUINT64(1);
+  EXPECT_TRUE(mxIsUint64(uint64_scalar));{
+  EXXPECT_EQ(mxGetNumberOfElements(uint64_scalar), 1);
+  EXPECT_EQ(*((UINT64_T *) mxGetData(uint64_scalar)), 1);
+
+}
+
+}  // maoxdb