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

v0.27.3
Luis Díaz Más 8 years ago committed by Luis Diaz Mas
parent 89629f0056
commit 26189ad287

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

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

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

@ -0,0 +1,9 @@
add_executable(unit_tests mainTestRunner.cpp
test_types.cpp
)
target_link_libraries(unit_tests
PRIVATE
exiv2lib
GTest::GTest
)

@ -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;
}

@ -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
}
Loading…
Cancel
Save