mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-28 21:01:04 +00:00
gtest: move GTest/GMock files to separate directory, update GTest/GMock usages
* all GTest/GMock files moved to `test/gtest` directory * `CMakeLists.txt` created in `test/gtest` from `CMakeLists.txt` in `test` * GTest/GMock target in CMake renamed to `gtest` (was `gmock`) * CMake `gtest` target updated to export includes as "gtest/gtest.h" or "gmock/gmock.h" only * includes in tests updated: "gtest.h" -> "gtest/gtest.h", "gmock.h" -> "gmock/gmock.h" * removed duplications of `target_include_directories` for GTest/GMock directories (CMake manages them)
This commit is contained in:
parent
342973b349
commit
53ca0cbe75
@ -1,44 +1,11 @@
|
|||||||
#------------------------------------------------------------------------------
|
add_subdirectory(gtest)
|
||||||
# Build the google test library
|
|
||||||
|
|
||||||
# We compile Google Test ourselves instead of using pre-compiled libraries.
|
|
||||||
# See the Google Test FAQ "Why is it not recommended to install a
|
|
||||||
# pre-compiled copy of Google Test (for example, into /usr/local)?"
|
|
||||||
# at http://code.google.com/p/googletest/wiki/FAQ for more details.
|
|
||||||
add_library(gmock STATIC
|
|
||||||
gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h)
|
|
||||||
target_compile_definitions(gmock PUBLIC GTEST_HAS_STD_WSTRING=1)
|
|
||||||
target_include_directories(gmock SYSTEM PUBLIC . gmock gtest)
|
|
||||||
|
|
||||||
find_package(Threads)
|
|
||||||
if (Threads_FOUND)
|
|
||||||
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
else ()
|
|
||||||
target_compile_definitions(gmock PUBLIC GTEST_HAS_PTHREAD=0)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
target_compile_definitions(gmock PUBLIC GTEST_LANG_CXX11=1)
|
|
||||||
|
|
||||||
if (MSVC)
|
|
||||||
# Disable MSVC warnings of _CRT_INSECURE_DEPRECATE functions.
|
|
||||||
target_compile_definitions(gmock PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
# Disable MSVC warnings of POSIX functions.
|
|
||||||
target_compile_options(gmock PUBLIC -Wno-deprecated-declarations)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Silence MSVC tr1 deprecation warning in gmock.
|
|
||||||
target_compile_definitions(gmock
|
|
||||||
PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Build the actual library tests
|
# Build the actual library tests
|
||||||
|
|
||||||
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
|
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
|
||||||
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
add_library(test-main STATIC ${TEST_MAIN_SRC})
|
||||||
target_include_directories(test-main SYSTEM PUBLIC gtest gmock)
|
target_link_libraries(test-main gtest fmt)
|
||||||
target_link_libraries(test-main gmock fmt)
|
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
@ -75,7 +42,6 @@ function(add_fmt_test name)
|
|||||||
if (FMT_WERROR)
|
if (FMT_WERROR)
|
||||||
target_compile_options(${name} PRIVATE ${WERROR_FLAG})
|
target_compile_options(${name} PRIVATE ${WERROR_FLAG})
|
||||||
endif ()
|
endif ()
|
||||||
target_include_directories(${name} SYSTEM PUBLIC gtest gmock)
|
|
||||||
add_test(NAME ${name} COMMAND ${name})
|
add_test(NAME ${name} COMMAND ${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -122,8 +88,7 @@ if (NOT MSVC_STATIC_RUNTIME)
|
|||||||
posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC})
|
posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||||
target_link_libraries(posix-mock-test gmock)
|
target_link_libraries(posix-mock-test gtest)
|
||||||
target_include_directories(posix-mock-test SYSTEM PUBLIC gtest gmock)
|
|
||||||
if (FMT_PEDANTIC)
|
if (FMT_PEDANTIC)
|
||||||
target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
|
target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
|
||||||
endif ()
|
endif ()
|
||||||
@ -136,8 +101,7 @@ endif ()
|
|||||||
|
|
||||||
add_fmt_executable(header-only-test
|
add_fmt_executable(header-only-test
|
||||||
header-only-test.cc header-only-test2.cc test-main.cc)
|
header-only-test.cc header-only-test2.cc test-main.cc)
|
||||||
target_link_libraries(header-only-test gmock)
|
target_link_libraries(header-only-test gtest)
|
||||||
target_include_directories(header-only-test SYSTEM PUBLIC gtest gmock)
|
|
||||||
if (TARGET fmt-header-only)
|
if (TARGET fmt-header-only)
|
||||||
target_link_libraries(header-only-test fmt-header-only)
|
target_link_libraries(header-only-test fmt-header-only)
|
||||||
else ()
|
else ()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "fmt/args.h"
|
#include "fmt/args.h"
|
||||||
|
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(args_test, basic) {
|
TEST(args_test, basic) {
|
||||||
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
auto store = fmt::dynamic_format_arg_store<fmt::format_context>();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
// For the license information refer to format.h.
|
// For the license information refer to format.h.
|
||||||
|
|
||||||
#include "fmt/core.h"
|
#include "fmt/core.h"
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(assert_test, fail) {
|
TEST(assert_test, fail) {
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "fmt/chrono.h"
|
#include "fmt/chrono.h"
|
||||||
#include "fmt/compile.h"
|
#include "fmt/compile.h"
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <string> // std::string
|
#include <string> // std::string
|
||||||
#include <type_traits> // std::is_same
|
#include <type_traits> // std::is_same
|
||||||
|
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
|
|
||||||
#if defined(FMT_COMPILE_TIME_CHECKS) && FMT_COMPILE_TIME_CHECKS
|
#if defined(FMT_COMPILE_TIME_CHECKS) && FMT_COMPILE_TIME_CHECKS
|
||||||
# include "fmt/format.h"
|
# include "fmt/format.h"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "../src/format.cc"
|
#include "../src/format.cc"
|
||||||
#include "fmt/printf.h"
|
#include "fmt/printf.h"
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#undef index
|
#undef index
|
||||||
|
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "mock-allocator.h"
|
#include "mock-allocator.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "fmt/os.h"
|
#include "fmt/os.h"
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
|
|
||||||
#define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \
|
#define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \
|
||||||
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
|
||||||
|
33
test/gtest/CMakeLists.txt
Normal file
33
test/gtest/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Build the google test library
|
||||||
|
|
||||||
|
# We compile Google Test ourselves instead of using pre-compiled libraries.
|
||||||
|
# See the Google Test FAQ "Why is it not recommended to install a
|
||||||
|
# pre-compiled copy of Google Test (for example, into /usr/local)?"
|
||||||
|
# at http://code.google.com/p/googletest/wiki/FAQ for more details.
|
||||||
|
add_library(gtest STATIC
|
||||||
|
gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h)
|
||||||
|
target_compile_definitions(gtest PUBLIC GTEST_HAS_STD_WSTRING=1)
|
||||||
|
target_include_directories(gtest SYSTEM PUBLIC .)
|
||||||
|
|
||||||
|
find_package(Threads)
|
||||||
|
if (Threads_FOUND)
|
||||||
|
target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
else ()
|
||||||
|
target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
target_compile_definitions(gtest PUBLIC GTEST_LANG_CXX11=1)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
# Disable MSVC warnings of _CRT_INSECURE_DEPRECATE functions.
|
||||||
|
target_compile_definitions(gtest PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
# Disable MSVC warnings of POSIX functions.
|
||||||
|
target_compile_options(gtest PUBLIC -Wno-deprecated-declarations)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Silence MSVC tr1 deprecation warning in gmock.
|
||||||
|
target_compile_definitions(gtest
|
||||||
|
PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
|
|
||||||
using fmt::detail::max_value;
|
using fmt::detail::max_value;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define FMT_MOCK_ALLOCATOR_H_
|
#define FMT_MOCK_ALLOCATOR_H_
|
||||||
|
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
|
|
||||||
template <typename T> class mock_allocator {
|
template <typename T> class mock_allocator {
|
||||||
public:
|
public:
|
||||||
|
@ -24,7 +24,7 @@ template <> struct formatter<test> : formatter<int> {
|
|||||||
|
|
||||||
#include "fmt/ostream.h"
|
#include "fmt/ostream.h"
|
||||||
#include "fmt/ranges.h"
|
#include "fmt/ranges.h"
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
# undef ERROR
|
# undef ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601
|
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601
|
||||||
# define FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY
|
# define FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
#include "gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
|
|
||||||
TEST(ScanTest, ReadText) {
|
TEST(ScanTest, ReadText) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <format>
|
#include <format>
|
||||||
|
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(StdFormatTest, Escaping) {
|
TEST(StdFormatTest, Escaping) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
class assertion_failure : public std::logic_error {
|
class assertion_failure : public std::logic_error {
|
||||||
public:
|
public:
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user