From 02702874f63f128ebe0310b804c592d829faa2a2 Mon Sep 17 00:00:00 2001 From: Phuntsok Drak-pa Date: Wed, 27 Mar 2019 14:31:25 +0100 Subject: [PATCH] added files for running tests --- CMakeLists.txt | 6 ++++++ conanfile.py | 2 +- tests/tests.cc | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/tests.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index c41ca55..9a3a26b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ project("GeneticImages" LANGUAGES CXX) file(GLOB SRC_FILES "src/*.cc") +file(GLOB TEST_FILES "tests/tests.cc") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -21,10 +22,15 @@ enable_cxx_compiler_flag_if_supported("-flto") # include_directories() set(TGT genetic-image) +set(TESTTGT genetic-image-tests) add_executable(${TGT} ${SRC_FILES}) +add_executable(${TESTTGT} ${TEST_FILES}) target_compile_features(${TGT} PRIVATE cxx_std_17) +target_compile_features(${TESTTGT} PRIVATE cxx_std_17) target_include_directories(${TGT} PRIVATE include/genimg) +target_include_directories(${TESTTGT} PRIVATE include/genimg) target_link_libraries(${TGT} ${CONAN_LIBS} stdc++fs) +target_link_libraries(${TESTTGT} ${CONAN_LIBS} stdc++fs) # OS specific instructions. if(APPLE) diff --git a/conanfile.py b/conanfile.py index 686f367..b09b39e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,7 +3,7 @@ from conans import CMake, ConanFile class GeneticImageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - requires = "opencv/4.0.1@conan/stable", "boost/1.69.0@conan/stable", "spdlog/1.3.1@bincrafters/stable" + requires = "opencv/4.0.1@conan/stable", "boost/1.69.0@conan/stable", "spdlog/1.3.1@bincrafters/stable", "gtest/1.8.1@bincrafters/stable" generators = "cmake", "gcc", "txt" def imports(self): diff --git a/tests/tests.cc b/tests/tests.cc new file mode 100644 index 0000000..46dbcf3 --- /dev/null +++ b/tests/tests.cc @@ -0,0 +1,16 @@ +#include + +TEST(SquareRootTest, PositiveNos) { + ASSERT_EQ(6, 2 * 3); + ASSERT_EQ(6, -2 * -3); +} + +TEST(SquareRootTest, NegativeNos) { + ASSERT_EQ(-6, -2 * 3); + ASSERT_EQ(-6, 2 * -3); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}