(CMake) Add a new CMake option to enable the new Unit Tests

This commit is contained in:
Luis Díaz Más
2017-10-08 21:02:14 +02:00
committed by Luis Diaz Mas
parent 89629f0056
commit 26189ad287
6 changed files with 44 additions and 0 deletions
+5
View File
@@ -39,6 +39,7 @@ option( EXIV2_ENABLE_SSH "USE Libssh for SshIo"
option( EXIV2_BUILD_SAMPLES "Build sample applications" ON )
option( EXIV2_BUILD_PO "Build translations files" OFF )
option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON )
option( EXIV2_BUILD_UNIT_TESTS "Build unit tests" OFF )
if ( EXIV2_ENABLE_WEBREADY )
set ( EXIV2_ENABLE_CURL ON )
@@ -69,6 +70,10 @@ if( EXIV2_ENABLE_XMP )
endif()
add_subdirectory( src )
if( EXIV2_BUILD_UNIT_TESTS )
add_subdirectory ( unitTests )
endif()
if( EXIV2_BUILD_SAMPLES )
add_subdirectory( samples )
endif()
+4
View File
@@ -64,3 +64,7 @@ if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
if (EXIV2_BUILD_UNIT_TESTS)
find_package(GTest REQUIRED)
endif()
+1
View File
@@ -40,6 +40,7 @@ endif()
OptionOutput( "Building exiv2 command: " EXIV2_BUILD_EXIV2_COMMAND )
OptionOutput( "Building samples: " EXIV2_BUILD_SAMPLES )
OptionOutput( "Building PO files: " EXIV2_BUILD_PO )
OptionOutput( "Building unit tests: " EXIV2_BUILD_UNIT_TESTS )
message( STATUS "------------------------------------------------------------------" )
+9
View File
@@ -0,0 +1,9 @@
add_executable(unit_tests mainTestRunner.cpp
test_types.cpp
)
target_link_libraries(unit_tests
PRIVATE
exiv2lib
GTest::GTest
)
+14
View File
@@ -0,0 +1,14 @@
#include <gtest/gtest.h>
#include <iostream>
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
std::cout << "Tests finished with return value: " << ret << std::endl;
return EXIT_SUCCESS;
}
+11
View File
@@ -0,0 +1,11 @@
#include <gtest/gtest.h>
#include <exiv2/types.hpp>
using namespace Exiv2;
TEST(ExivTime, getsTimeFromValidString)
{
struct tm tmInstance;
ASSERT_EQ(0, exifTime("2007:05:24 12:31:55", &tmInstance));
/// \todo add more checks here
}