added files for running tests

This commit is contained in:
Phuntsok Drak-pa 2019-03-27 14:31:25 +01:00
parent 99c815a561
commit 02702874f6
3 changed files with 23 additions and 1 deletions

View File

@ -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(<PUBLIC HEADER 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)

View File

@ -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):

16
tests/tests.cc Normal file
View File

@ -0,0 +1,16 @@
#include <gtest/gtest.h>
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();
}