diff --git a/CMakeLists.txt b/CMakeLists.txt index 8de5134..88a3cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,9 @@ include_directories( ${fmt_INCLUDE_DIRS} ) find_package(Boost 1.63 COMPONENTS system REQUIRED ) include_directories( ${Boost_INCLUDE_DIRS} ) +find_package(GTest REQUIRED) + + add_library(core STATIC core/BackupFormatModel.cpp core/CsvWriter.cpp @@ -118,7 +121,7 @@ add_executable(pglab pglab/resources.qrc ) -target_include_directories(pglab PUBLIC +target_include_directories(pglab PRIVATE ./core ./pgsql ) @@ -132,3 +135,25 @@ target_link_libraries( pglab ${Botan_LIBRARIES} pthread ) + +add_executable(runtests + tests/main.cpp + tests/tst_CsvWriter.cpp + tests/tst_expected.cpp + tests/tst_PasswordManager.cpp + tests/tst_scopeguard.cpp + tests/tst_SqlLexer.cpp + ) + +target_include_directories(runtests PRIVATE ./core ${GTEST_INCLUDE_DIRS}) +target_link_libraries(runtests + core + ${GTEST_LIBRARIES} + ${Botan_LIBRARIES} + Qt5::Widgets + pthread + ) + + +enable_testing() +add_test(tests runtests) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro deleted file mode 100644 index 576a9ff..0000000 --- a/tests/auto/auto.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += mycase diff --git a/tests/auto/gtest_dependency.pri b/tests/auto/gtest_dependency.pri deleted file mode 100644 index d01d7f0..0000000 --- a/tests/auto/gtest_dependency.pri +++ /dev/null @@ -1,29 +0,0 @@ -isEmpty(GOOGLETEST_DIR):GOOGLETEST_DIR=$$(GOOGLETEST_DIR) - -isEmpty(GOOGLETEST_DIR) { - warning("Using googletest src dir specified at Qt Creator wizard") - message("set GOOGLETEST_DIR as environment variable or qmake variable to get rid of this message") - GOOGLETEST_DIR = C:/Prog/googletest -} - -!isEmpty(GOOGLETEST_DIR): { - GTEST_SRCDIR = $$GOOGLETEST_DIR/googletest - GMOCK_SRCDIR = $$GOOGLETEST_DIR/googlemock -} - -requires(exists($$GTEST_SRCDIR):exists($$GMOCK_SRCDIR)) - -!exists($$GOOGLETEST_DIR):message("No googletest src dir found - set GOOGLETEST_DIR to enable.") - -DEFINES += \ - GTEST_LANG_CXX11 - -INCLUDEPATH *= \ - $$GTEST_SRCDIR \ - $$GTEST_SRCDIR/include \ - $$GMOCK_SRCDIR \ - $$GMOCK_SRCDIR/include - -SOURCES += \ - $$GTEST_SRCDIR/src/gtest-all.cc \ - $$GMOCK_SRCDIR/src/gmock-all.cc diff --git a/tests/auto/mycase/main.cpp b/tests/auto/mycase/main.cpp deleted file mode 100644 index 046652f..0000000 --- a/tests/auto/mycase/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "tst_CsvWriter.h" -#include "tst_expected.h" -#include "tst_PasswordManager.h" -#include "tst_scopeguard.h" -#include "tst_SqlLexer.h" - -#include - -int main(int argc, char *argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/auto/mycase/mycase.pro b/tests/auto/mycase/mycase.pro deleted file mode 100644 index 8572e21..0000000 --- a/tests/auto/mycase/mycase.pro +++ /dev/null @@ -1,31 +0,0 @@ -include(../gtest_dependency.pri) - -TEMPLATE = app -CONFIG += console c++11 -CONFIG -= app_bundle -CONFIG += thread -CONFIG += qt - -QT += core - -HEADERS += \ - tst_expected.h \ - tst_SqlLexer.h \ - tst_scopeguard.h \ - tst_CsvWriter.h \ - tst_PasswordManager.h - -SOURCES += main.cpp - -win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../core/release/ -lcore -else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../core/debug/ -lcore - -INCLUDEPATH += C:\prog\include C:\VSproj\boost_1_63_0 -INCLUDEPATH += $$PWD/../../../core -DEPENDPATH += $$PWD/../../../core -LIBS += c:\prog\lib\botand_imp.lib - -win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/release/libcore.a -else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/debug/libcore.a -else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/release/core.lib -else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/debug/core.lib diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..65b7839 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc, char *argv[]) +{ + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/tests/tests.pro b/tests/tests.pro deleted file mode 100644 index f927700..0000000 --- a/tests/tests.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += auto diff --git a/tests/auto/mycase/tst_CsvWriter.h b/tests/tst_CsvWriter.cpp similarity index 100% rename from tests/auto/mycase/tst_CsvWriter.h rename to tests/tst_CsvWriter.cpp diff --git a/tests/auto/mycase/tst_PasswordManager.h b/tests/tst_PasswordManager.cpp similarity index 100% rename from tests/auto/mycase/tst_PasswordManager.h rename to tests/tst_PasswordManager.cpp diff --git a/tests/auto/mycase/tst_SqlLexer.h b/tests/tst_SqlLexer.cpp similarity index 100% rename from tests/auto/mycase/tst_SqlLexer.h rename to tests/tst_SqlLexer.cpp diff --git a/tests/auto/mycase/tst_expected.h b/tests/tst_expected.cpp similarity index 100% rename from tests/auto/mycase/tst_expected.h rename to tests/tst_expected.cpp diff --git a/tests/auto/mycase/tst_scopeguard.h b/tests/tst_scopeguard.cpp similarity index 100% rename from tests/auto/mycase/tst_scopeguard.h rename to tests/tst_scopeguard.cpp