summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-12 17:58:52 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-12 17:58:52 +0000
commit1a799bffa70e88369713cee9391a10e68cd072a9 (patch)
treeed09bb5c63b5bdcbc6fb7d4ba1602085d789f108 /test
parent57fe1769183f5e77600cc7ce6e1c417c70b2cf63 (diff)
downloadrspamd-1a799bffa70e88369713cee9391a10e68cd072a9.tar.gz
rspamd-1a799bffa70e88369713cee9391a10e68cd072a9.zip
[Project] Css: Add some c++ unit tests
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt10
-rw-r--r--test/rspamd_cxx_unit.cxx32
2 files changed, 42 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0d85b08de..934b141c7 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,6 +21,16 @@ IF(USE_CXX_LINKER)
ENDIF()
TARGET_LINK_LIBRARIES(rspamd-test rspamd-server)
+SET(CXXTESTSSRC rspamd_cxx_unit.cxx)
+
+ADD_EXECUTABLE(rspamd-test-cxx EXCLUDE_FROM_ALL ${CXXTESTSSRC})
+SET_TARGET_PROPERTIES(rspamd-test-cxx PROPERTIES LINKER_LANGUAGE CXX)
+ADD_DEPENDENCIES(rspamd-test-cxx rspamd-server)
+ADD_DEPENDENCIES(rspamd-test-cxx doctest)
+TARGET_LINK_LIBRARIES(rspamd-test-cxx PRIVATE rspamd-server)
+TARGET_LINK_LIBRARIES(rspamd-test-cxx PRIVATE doctest)
+SET_TARGET_PROPERTIES(rspamd-test-cxx PROPERTIES LINKER_LANGUAGE CXX)
+
IF(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
# Also add dependencies for convenience
FILE(GLOB_RECURSE LUA_TESTS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/lua/*.*")
diff --git a/test/rspamd_cxx_unit.cxx b/test/rspamd_cxx_unit.cxx
new file mode 100644
index 000000000..eb456d2fd
--- /dev/null
+++ b/test/rspamd_cxx_unit.cxx
@@ -0,0 +1,32 @@
+/*-
+ * Copyright 2021 Vsevolod Stakhov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "config.h"
+#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
+#include "doctest/doctest.h"
+
+int
+main(int argc, char** argv)
+{
+ doctest::Context context(argc, argv);
+ int res = context.run();
+
+ if(context.shouldExit()) {
+ return res;
+ }
+
+ return res;
+} \ No newline at end of file