tests: Add test_assert_macros.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7926cee..ea9b392 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,10 +35,6 @@
 include(DefineOptions.cmake)
 include(CPackConfig.cmake)
 
-if (UNIT_TESTING)
-    include(AddCMockaTest)
-endif (UNIT_TESTING)
-
 # disallow in-source build
 include(MacroEnsureOutOfSourceBuild)
 macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
@@ -51,8 +47,11 @@
 add_subdirectory(doc)
 add_subdirectory(include)
 add_subdirectory(src)
+add_subdirectory(example)
+
 if (UNIT_TESTING)
-    add_subdirectory(example)
+    include(AddCMockaTest)
+    add_subdirectory(tests)
 endif (UNIT_TESTING)
 
 # pkg-config file
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..019cb3e
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,14 @@
+project(tests C)
+
+include_directories(
+  ${CMAKE_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_SOURCE_DIR}/include
+)
+
+set(CMOCKA_TESTS
+    test_assert_macros)
+
+foreach(_CMOCKA_TEST ${CMOCKA_TESTS})
+    add_cmocka_test(${_CMOCKA_TEST} ${_CMOCKA_TEST}.c ${CMOCKA_SHARED_LIBRARY})
+endforeach()
diff --git a/tests/test_assert_macros.c b/tests/test_assert_macros.c
new file mode 100644
index 0000000..7f643b7
--- /dev/null
+++ b/tests/test_assert_macros.c
@@ -0,0 +1,33 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/**************************************
+ *** assert_return_code
+ **************************************/
+static void test_assert_return_code(void **state)
+{
+    struct stat sb;
+    int rc;
+
+    (void)state; /* unused */
+
+    rc = stat(".", &sb);
+    assert_return_code(rc, 0);
+
+    assert_true(S_ISDIR(sb.st_mode));
+}
+
+int main(void) {
+    const UnitTest tests[] = {
+        unit_test(test_assert_return_code),
+    };
+    return run_tests(tests);
+}