From caa35b36acbb6105834af761d17b063b3706f633 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 21:03:59 +0200 Subject: [PATCH 1/4] more on database --- src/core/database.cpp | 10 ++++++++++ src/core/database.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/core/database.cpp b/src/core/database.cpp index 1ad5f43..0b3207a 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -18,4 +18,14 @@ void Database::exec(const std::string& sql) if (errCode) { throw std::runtime_error("Error in SQL execution."); } +} + +void Database::beginTransaction() +{ + exec("BEGIN TRANSACTION"); +} + +void Database::endTransaction() +{ + exec("END TRANSACTION"); } \ No newline at end of file diff --git a/src/core/database.h b/src/core/database.h index dcb2858..5fcf027 100644 --- a/src/core/database.h +++ b/src/core/database.h @@ -15,6 +15,8 @@ public: void exec(const std::string& sql); private: sqlite3 *db; + void beginTransaction(); + void endTransaction(); }; #endif // DATABASE_H \ No newline at end of file From 47adab40ae8429f845aacf38e8aa91f0816f74e3 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 21:42:04 +0200 Subject: [PATCH 2/4] ... --- test/test_seller.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_seller.cpp b/test/test_seller.cpp index 456acad..c467906 100644 --- a/test/test_seller.cpp +++ b/test/test_seller.cpp @@ -1,7 +1,7 @@ -#include "../src/core/seller.h" - #define BOOST_TEST_MODULE seller +#include "../src/core/seller.h" + #include using namespace boost::unit_test; From 3b1f2d346fc1349f5a29b21a83c2acce8f5625ac Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 21:42:38 +0200 Subject: [PATCH 3/4] added database test --- test/test_database.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/test_database.cpp diff --git a/test/test_database.cpp b/test/test_database.cpp new file mode 100644 index 0000000..982a174 --- /dev/null +++ b/test/test_database.cpp @@ -0,0 +1,11 @@ +#define BOOST_TEST_MODULE database + +#include "../src/core/database.h" + +#include + +//using namespace boost::unit_test; + +BOOST_AUTO_TEST_CASE( create_database ) { + Database db("test.db"); +} \ No newline at end of file From 97e444c91ce0dfe1396d621d3afd64e61047ad9e Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Mon, 9 Jul 2018 21:43:08 +0200 Subject: [PATCH 4/4] fixed testing setup --- CMakeLists.txt | 4 +++- test/CMakeLists.txt | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a43511..4d9f0a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,5 +17,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +enable_testing() + add_subdirectory(src) -add_subdirectory(test) \ No newline at end of file +add_subdirectory(test) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dde9034..f89cd4a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,8 +1,9 @@ -enable_testing() - find_package(Boost COMPONENTS filesystem unit_test_framework REQUIRED) -set(TEST_SOURCES test_seller.cpp) +add_executable(sellertest test_seller.cpp) +target_link_libraries(sellertest core Boost::boost Boost::filesystem Boost::unit_test_framework) +add_test(Seller ${CMAKE_BINARY_DIR}/bin/sellertest) -add_executable(testsuite ${TEST_SOURCES}) -target_link_libraries(testsuite core Boost::boost Boost::filesystem Boost::unit_test_framework) +add_executable(databasetest test_database.cpp) +target_link_libraries(databasetest core Boost::boost Boost::filesystem Boost::unit_test_framework) +add_test(Database ${CMAKE_BINARY_DIR}/bin/databasetest)