diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-05-31 02:48:39 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-06-07 12:58:08 +0200 |
| commit | 3e8a1984e9ee662e74254704275c8e30791a5af0 (patch) | |
| tree | 1964e31d65b0703d72a29c3864083eef3a325ed5 /test/unit | |
| parent | 9c5741d25229308971b83798fae55e3045910521 (diff) | |
| download | PROJ-3e8a1984e9ee662e74254704275c8e30791a5af0.tar.gz PROJ-3e8a1984e9ee662e74254704275c8e30791a5af0.zip | |
Add googletest 1.8.0 framework in test/googletest, and use it with autoconf builds only (CMake integration to be done)
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/CMakeLists.txt | 24 | ||||
| -rw-r--r-- | test/unit/Makefile.am | 11 | ||||
| -rw-r--r-- | test/unit/basic_test.cpp | 10 | ||||
| -rw-r--r-- | test/unit/gtest_include.h | 36 | ||||
| -rw-r--r-- | test/unit/main.cpp | 34 |
5 files changed, 97 insertions, 18 deletions
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index c9aa8741..899aec9b 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -1,13 +1,13 @@ -SET(CATCH2_INCLUDE ../catch.hpp) -include_directories(..) +#SET(CATCH2_INCLUDE ../catch.hpp) +#include_directories(..) -SET(BASIC_TEST_SRC basic_test.cpp) -add_executable(basic_test ${BASIC_TEST_SRC} ${CATCH2_INCLUDE}) -target_link_libraries(basic_test ${PROJ_LIBRARIES} ${TEST_MAIN_LIBRARIES}) -set_target_properties(basic_test - PROPERTIES - LINKER_LANGUAGE CXX) - -add_test( NAME basic_test - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test - COMMAND basic_test ) +#SET(BASIC_TEST_SRC basic_test.cpp) +#add_executable(basic_test ${BASIC_TEST_SRC} ${CATCH2_INCLUDE}) +#target_link_libraries(basic_test ${PROJ_LIBRARIES} ${TEST_MAIN_LIBRARIES}) +#set_target_properties(basic_test +# PROPERTIES +# LINKER_LANGUAGE CXX) +# +#add_test( NAME basic_test +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test +# COMMAND basic_test ) diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am index 3476dd96..234ee1bd 100644 --- a/test/unit/Makefile.am +++ b/test/unit/Makefile.am @@ -1,11 +1,16 @@ +AUTOMAKE_OPTIONS = subdir-objects + EXTRA_DIST = CMakeLists.txt -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test +include_HEADERS = gtest_include.h + +AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/test/googletest/include +AM_CXXFLAGS = @CXX_WFLAGS@ @NO_ZERO_AS_NULL_POINTER_CONSTANT_FLAG@ bin_PROGRAMS = basic_test -basic_test_SOURCES = basic_test.cpp -basic_test_LDADD = ../../src/libproj.la ../../test/libtestmain.la +basic_test_SOURCES = basic_test.cpp main.cpp +basic_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la basic_test-check: basic_test ./basic_test diff --git a/test/unit/basic_test.cpp b/test/unit/basic_test.cpp index 5a153331..8ee82bf4 100644 --- a/test/unit/basic_test.cpp +++ b/test/unit/basic_test.cpp @@ -26,10 +26,14 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "catch.hpp" +#include "gtest_include.h" + +namespace { // --------------------------------------------------------------------------- -TEST_CASE( "dumy" ) { - CHECK( 1 == 1 ); +TEST( dumy, dummy ) { + ASSERT_EQ( 1 , 1 ); } + +} // namespace diff --git a/test/unit/gtest_include.h b/test/unit/gtest_include.h new file mode 100644 index 00000000..d3088feb --- /dev/null +++ b/test/unit/gtest_include.h @@ -0,0 +1,36 @@ +/****************************************************************************** + * + * Project: PROJ + * Purpose: Wrapper for gtest/gtest.h + * Author: Even Rouault <even dot rouault at spatialys dot com> + * + ****************************************************************************** + * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************/ + +// Disable all warnings for gtest.h, so as to be able to still use them for +// our own code. + +#if defined(__GNUC__) +#pragma GCC system_header +#endif + +#include "gtest/gtest.h" diff --git a/test/unit/main.cpp b/test/unit/main.cpp new file mode 100644 index 00000000..ffa95e03 --- /dev/null +++ b/test/unit/main.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * + * Project: PROJ + * Purpose: gtest main + * Author: Even Rouault <even dot rouault at spatialys dot com> + * + ****************************************************************************** + * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************/ + +#include "gtest_include.h" + +GTEST_API_ int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} |
