From 59c4beff212b7bbb6b05e2928ddfede370de3811 Mon Sep 17 00:00:00 2001 From: Nathan Osman Date: Mon, 1 Jul 2013 11:25:12 -0700 Subject: [PATCH] Added tests directory, which will eventually contain the unit tests for the QRedis client library. --- CMakeLists.txt | 11 ++++++++++- src/client.cpp | 2 +- tests/CMakeLists.txt | 12 ++++++++++++ tests/main.cpp | 6 ++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a8973ad..1e257ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.8.9) project(qredis) +# These options can be used to control the build process. +option(BUILD_TESTS "Build the QRedis test suite" ON) + # These definitions are used to set the target properties later on. set(QREDIS_MAJOR 0) set(QREDIS_MINOR 1) @@ -48,7 +51,7 @@ set_target_properties(qredis PROPERTIES SOVERSION ${QREDIS_MAJOR}) # This causes the appropriate libraries to be included in the link process. -qt5_use_modules(qredis Network) +qt5_use_modules(qredis Core Network) # Specify the proper installation paths. install(TARGETS qredis @@ -56,3 +59,9 @@ install(TARGETS qredis ARCHIVE DESTINATION lib RUNTIME DESTINATION bin PUBLIC_HEADER DESTINATION include/qredis) + +# If the tests are to be built, then add them to the project. +if(BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/src/client.cpp b/src/client.cpp index 8f43de3..cfa3eaf 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -70,7 +70,7 @@ void ClientPrivate::readReply() } Client::Client(QObject * parent) - : QObject(parent), d(new ClientPrivate) + : QObject(parent), d(new ClientPrivate(this)) { } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..dd4a44f --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,12 @@ +# The QtTest libraries are required for building the tests. +find_package(Qt5Test REQUIRED) + +# Create the test executable. +add_executable(qredis-tests + main.cpp) + +# Specify the Qt modules the test executable links against. +qt5_use_modules(qredis-tests Core Test) + +# Naturally, we also link against the QRedis library. +target_link_libraries(qredis-tests qredis) diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..9179de7 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,6 @@ +#include + +int main(int argc, char ** argv) +{ + return 0; +}