Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a6ce08abf7 | ||
![]() |
c00fd25b71 | ||
![]() |
4a00a24fff | ||
![]() |
a866428a78 |
@ -1,10 +1,10 @@
|
|||||||
# Note: CMake support is community-based. The maintainers do not use CMake
|
# Note: CMake support is community-based. The maintainers do not use CMake
|
||||||
# internally.
|
# internally.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(googletest-distribution)
|
project(googletest-distribution)
|
||||||
set(GOOGLETEST_VERSION 1.15.2)
|
set(GOOGLETEST_VERSION 1.16.0)
|
||||||
|
|
||||||
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
|
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
11
README.md
11
README.md
@ -9,7 +9,7 @@ GoogleTest now follows the
|
|||||||
We recommend
|
We recommend
|
||||||
[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it).
|
[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it).
|
||||||
We do publish occasional semantic versions, tagged with
|
We do publish occasional semantic versions, tagged with
|
||||||
`v${major}.${minor}.${patch}` (e.g. `v1.15.2`).
|
`v${major}.${minor}.${patch}` (e.g. `v1.16.0`).
|
||||||
|
|
||||||
#### Documentation Updates
|
#### Documentation Updates
|
||||||
|
|
||||||
@ -17,12 +17,15 @@ Our documentation is now live on GitHub Pages at
|
|||||||
https://google.github.io/googletest/. We recommend browsing the documentation on
|
https://google.github.io/googletest/. We recommend browsing the documentation on
|
||||||
GitHub Pages rather than directly in the repository.
|
GitHub Pages rather than directly in the repository.
|
||||||
|
|
||||||
#### Release 1.15.2
|
#### Release 1.16.0
|
||||||
|
|
||||||
[Release 1.15.2](https://github.com/google/googletest/releases/tag/v1.15.2) is
|
[Release 1.16.0](https://github.com/google/googletest/releases/tag/v1.16.0) is
|
||||||
now available.
|
now available.
|
||||||
|
|
||||||
The 1.15.x branch requires at least C++14.
|
The 1.16.x branch requires at least C++14.
|
||||||
|
|
||||||
|
The 1.16.x branch will be the last to support C++14. Future development will
|
||||||
|
[require at least C++17](https://opensource.google/documentation/policies/cplusplus-support#c_language_standard).
|
||||||
|
|
||||||
#### Continuous Integration
|
#### Continuous Integration
|
||||||
|
|
||||||
|
@ -39,43 +39,60 @@ if [[ -z ${GTEST_ROOT:-} ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${STD:-} ]]; then
|
if [[ -z ${STD:-} ]]; then
|
||||||
STD="c++14 c++17 c++20"
|
STD="c++17 c++20"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test the CMake build
|
# Test CMake + GCC
|
||||||
for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do
|
for cmake_off_on in OFF ON; do
|
||||||
for cmake_off_on in OFF ON; do
|
time docker run \
|
||||||
time docker run \
|
--volume="${GTEST_ROOT}:/src:ro" \
|
||||||
--volume="${GTEST_ROOT}:/src:ro" \
|
--tmpfs="/build:exec" \
|
||||||
--tmpfs="/build:exec" \
|
--workdir="/build" \
|
||||||
--workdir="/build" \
|
--rm \
|
||||||
--rm \
|
--env="CC=/usr/local/bin/gcc" \
|
||||||
--env="CC=${cc}" \
|
--env=CXXFLAGS="-Werror -Wdeprecated" \
|
||||||
--env=CXXFLAGS="-Werror -Wdeprecated" \
|
${LINUX_LATEST_CONTAINER} \
|
||||||
${LINUX_LATEST_CONTAINER} \
|
/bin/bash -c "
|
||||||
/bin/bash -c "
|
cmake /src \
|
||||||
cmake /src \
|
-DCMAKE_CXX_STANDARD=17 \
|
||||||
-DCMAKE_CXX_STANDARD=14 \
|
-Dgtest_build_samples=ON \
|
||||||
-Dgtest_build_samples=ON \
|
-Dgtest_build_tests=ON \
|
||||||
-Dgtest_build_tests=ON \
|
-Dgmock_build_tests=ON \
|
||||||
-Dgmock_build_tests=ON \
|
-Dcxx_no_exception=${cmake_off_on} \
|
||||||
-Dcxx_no_exception=${cmake_off_on} \
|
-Dcxx_no_rtti=${cmake_off_on} && \
|
||||||
-Dcxx_no_rtti=${cmake_off_on} && \
|
make -j$(nproc) && \
|
||||||
make -j$(nproc) && \
|
ctest -j$(nproc) --output-on-failure"
|
||||||
ctest -j$(nproc) --output-on-failure"
|
done
|
||||||
done
|
|
||||||
|
# Test CMake + Clang
|
||||||
|
for cmake_off_on in OFF ON; do
|
||||||
|
time docker run \
|
||||||
|
--volume="${GTEST_ROOT}:/src:ro" \
|
||||||
|
--tmpfs="/build:exec" \
|
||||||
|
--workdir="/build" \
|
||||||
|
--rm \
|
||||||
|
--env="CC=/opt/llvm/clang/bin/clang" \
|
||||||
|
--env=CXXFLAGS="-Werror -Wdeprecated --gcc-toolchain=/usr/local" \
|
||||||
|
${LINUX_LATEST_CONTAINER} \
|
||||||
|
/bin/bash -c "
|
||||||
|
cmake /src \
|
||||||
|
-DCMAKE_CXX_STANDARD=17 \
|
||||||
|
-Dgtest_build_samples=ON \
|
||||||
|
-Dgtest_build_tests=ON \
|
||||||
|
-Dgmock_build_tests=ON \
|
||||||
|
-Dcxx_no_exception=${cmake_off_on} \
|
||||||
|
-Dcxx_no_rtti=${cmake_off_on} && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
ctest -j$(nproc) --output-on-failure"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Do one test with an older version of GCC
|
# Do one test with an older version of GCC
|
||||||
# TODO(googletest-team): This currently uses Bazel 5. When upgrading to a
|
|
||||||
# version of Bazel that supports Bzlmod, add --enable_bzlmod=false to keep test
|
|
||||||
# coverage for the old WORKSPACE dependency management.
|
|
||||||
time docker run \
|
time docker run \
|
||||||
--volume="${GTEST_ROOT}:/src:ro" \
|
--volume="${GTEST_ROOT}:/src:ro" \
|
||||||
--workdir="/src" \
|
--workdir="/src" \
|
||||||
--rm \
|
--rm \
|
||||||
--env="CC=/usr/local/bin/gcc" \
|
--env="CC=/usr/local/bin/gcc" \
|
||||||
--env="BAZEL_CXXOPTS=-std=c++14" \
|
--env="BAZEL_CXXOPTS=-std=c++17" \
|
||||||
${LINUX_GCC_FLOOR_CONTAINER} \
|
${LINUX_GCC_FLOOR_CONTAINER} \
|
||||||
/usr/local/bin/bazel test ... \
|
/usr/local/bin/bazel test ... \
|
||||||
--copt="-Wall" \
|
--copt="-Wall" \
|
||||||
@ -83,6 +100,7 @@ time docker run \
|
|||||||
--copt="-Wuninitialized" \
|
--copt="-Wuninitialized" \
|
||||||
--copt="-Wundef" \
|
--copt="-Wundef" \
|
||||||
--copt="-Wno-error=pragmas" \
|
--copt="-Wno-error=pragmas" \
|
||||||
|
--enable_bzlmod=false \
|
||||||
--features=external_include_paths \
|
--features=external_include_paths \
|
||||||
--keep_going \
|
--keep_going \
|
||||||
--show_timestamps \
|
--show_timestamps \
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
set -euox pipefail
|
set -euox pipefail
|
||||||
|
|
||||||
|
# Use Xcode 16.0
|
||||||
|
sudo xcode-select -s /Applications/Xcode_16.0.app/Contents/Developer
|
||||||
|
|
||||||
if [[ -z ${GTEST_ROOT:-} ]]; then
|
if [[ -z ${GTEST_ROOT:-} ]]; then
|
||||||
GTEST_ROOT="$(realpath $(dirname ${0})/..)"
|
GTEST_ROOT="$(realpath $(dirname ${0})/..)"
|
||||||
fi
|
fi
|
||||||
@ -40,20 +43,20 @@ for cmake_off_on in OFF ON; do
|
|||||||
BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX)
|
BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX)
|
||||||
cd ${BUILD_DIR}
|
cd ${BUILD_DIR}
|
||||||
time cmake ${GTEST_ROOT} \
|
time cmake ${GTEST_ROOT} \
|
||||||
-DCMAKE_CXX_STANDARD=14 \
|
-DCMAKE_CXX_STANDARD=17 \
|
||||||
-Dgtest_build_samples=ON \
|
-Dgtest_build_samples=ON \
|
||||||
-Dgtest_build_tests=ON \
|
-Dgtest_build_tests=ON \
|
||||||
-Dgmock_build_tests=ON \
|
-Dgmock_build_tests=ON \
|
||||||
-Dcxx_no_exception=${cmake_off_on} \
|
-Dcxx_no_exception=${cmake_off_on} \
|
||||||
-Dcxx_no_rtti=${cmake_off_on}
|
-Dcxx_no_rtti=${cmake_off_on}
|
||||||
time make
|
time make -j$(nproc)
|
||||||
time ctest -j$(nproc) --output-on-failure
|
time ctest -j$(nproc) --output-on-failure
|
||||||
done
|
done
|
||||||
|
|
||||||
# Test the Bazel build
|
# Test the Bazel build
|
||||||
|
|
||||||
# If we are running on Kokoro, check for a versioned Bazel binary.
|
# If we are running on Kokoro, check for a versioned Bazel binary.
|
||||||
KOKORO_GFILE_BAZEL_BIN="bazel-7.0.0-darwin-x86_64"
|
KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64"
|
||||||
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
|
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
|
||||||
BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
|
BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
|
||||||
chmod +x ${BAZEL_BIN}
|
chmod +x ${BAZEL_BIN}
|
||||||
@ -67,7 +70,7 @@ for absl in 0 1; do
|
|||||||
--copt="-Wall" \
|
--copt="-Wall" \
|
||||||
--copt="-Werror" \
|
--copt="-Werror" \
|
||||||
--copt="-Wundef" \
|
--copt="-Wundef" \
|
||||||
--cxxopt="-std=c++14" \
|
--cxxopt="-std=c++17" \
|
||||||
--define="absl=${absl}" \
|
--define="absl=${absl}" \
|
||||||
--enable_bzlmod=true \
|
--enable_bzlmod=true \
|
||||||
--features=external_include_paths \
|
--features=external_include_paths \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||||
|
|
||||||
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-7.0.0-windows-x86_64.exe
|
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe
|
||||||
|
|
||||||
SET PATH=C:\Python34;%PATH%
|
SET PATH=C:\Python34;%PATH%
|
||||||
SET BAZEL_PYTHON=C:\python34\python.exe
|
SET BAZEL_PYTHON=C:\python34\python.exe
|
||||||
@ -11,21 +11,18 @@ SET CTEST_OUTPUT_ON_FAILURE=1
|
|||||||
SET CMAKE_BUILD_PARALLEL_LEVEL=16
|
SET CMAKE_BUILD_PARALLEL_LEVEL=16
|
||||||
SET CTEST_PARALLEL_LEVEL=16
|
SET CTEST_PARALLEL_LEVEL=16
|
||||||
|
|
||||||
IF EXIST git\googletest (
|
SET GTEST_ROOT=%~dp0\..
|
||||||
CD git\googletest
|
|
||||||
) ELSE IF EXIST github\googletest (
|
|
||||||
CD github\googletest
|
|
||||||
)
|
|
||||||
|
|
||||||
IF %errorlevel% neq 0 EXIT /B 1
|
IF %errorlevel% neq 0 EXIT /B 1
|
||||||
|
|
||||||
:: ----------------------------------------------------------------------------
|
:: ----------------------------------------------------------------------------
|
||||||
:: CMake
|
:: CMake
|
||||||
MKDIR cmake_msvc2022
|
SET CMAKE_BUILD_PATH=cmake_msvc2022
|
||||||
CD cmake_msvc2022
|
MKDIR %CMAKE_BUILD_PATH%
|
||||||
|
CD %CMAKE_BUILD_PATH%
|
||||||
|
|
||||||
%CMAKE_BIN% .. ^
|
%CMAKE_BIN% %GTEST_ROOT% ^
|
||||||
-G "Visual Studio 17 2022" ^
|
-G "Visual Studio 17 2022" ^
|
||||||
|
-DCMAKE_CXX_STANDARD=17 ^
|
||||||
-DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
|
-DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
|
||||||
-DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
|
-DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
|
||||||
-DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
|
-DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
|
||||||
@ -40,8 +37,8 @@ IF %errorlevel% neq 0 EXIT /B 1
|
|||||||
%CTEST_BIN% -C Debug --timeout 600
|
%CTEST_BIN% -C Debug --timeout 600
|
||||||
IF %errorlevel% neq 0 EXIT /B 1
|
IF %errorlevel% neq 0 EXIT /B 1
|
||||||
|
|
||||||
CD ..
|
CD %GTEST_ROOT%
|
||||||
RMDIR /S /Q cmake_msvc2022
|
RMDIR /S /Q %CMAKE_BUILD_PATH%
|
||||||
|
|
||||||
:: ----------------------------------------------------------------------------
|
:: ----------------------------------------------------------------------------
|
||||||
:: Bazel
|
:: Bazel
|
||||||
@ -50,11 +47,26 @@ RMDIR /S /Q cmake_msvc2022
|
|||||||
:: because of Windows limitations on path length.
|
:: because of Windows limitations on path length.
|
||||||
:: --output_user_root=C:\tmp causes Bazel to use a shorter path.
|
:: --output_user_root=C:\tmp causes Bazel to use a shorter path.
|
||||||
SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
|
SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
|
||||||
|
|
||||||
|
:: C++17
|
||||||
%BAZEL_EXE% ^
|
%BAZEL_EXE% ^
|
||||||
--output_user_root=C:\tmp ^
|
--output_user_root=C:\tmp ^
|
||||||
test ... ^
|
test ... ^
|
||||||
--compilation_mode=dbg ^
|
--compilation_mode=dbg ^
|
||||||
--copt=/std:c++14 ^
|
--copt=/std:c++17 ^
|
||||||
|
--copt=/WX ^
|
||||||
|
--enable_bzlmod=true ^
|
||||||
|
--keep_going ^
|
||||||
|
--test_output=errors ^
|
||||||
|
--test_tag_filters=-no_test_msvc2017
|
||||||
|
IF %errorlevel% neq 0 EXIT /B 1
|
||||||
|
|
||||||
|
:: C++20
|
||||||
|
%BAZEL_EXE% ^
|
||||||
|
--output_user_root=C:\tmp ^
|
||||||
|
test ... ^
|
||||||
|
--compilation_mode=dbg ^
|
||||||
|
--copt=/std:c++20 ^
|
||||||
--copt=/WX ^
|
--copt=/WX ^
|
||||||
--enable_bzlmod=true ^
|
--enable_bzlmod=true ^
|
||||||
--keep_going ^
|
--keep_going ^
|
||||||
|
@ -24,7 +24,8 @@ provided by GoogleTest. All actions are defined in the `::testing` namespace.
|
|||||||
| :--------------------------------- | :-------------------------------------- |
|
| :--------------------------------- | :-------------------------------------- |
|
||||||
| `Assign(&variable, value)` | Assign `value` to variable. |
|
| `Assign(&variable, value)` | Assign `value` to variable. |
|
||||||
| `DeleteArg<N>()` | Delete the `N`-th (0-based) argument, which must be a pointer. |
|
| `DeleteArg<N>()` | Delete the `N`-th (0-based) argument, which must be a pointer. |
|
||||||
| `SaveArg<N>(pointer)` | Save the `N`-th (0-based) argument to `*pointer`. |
|
| `SaveArg<N>(pointer)` | Save the `N`-th (0-based) argument to `*pointer` by copy-assignment. |
|
||||||
|
| `SaveArgByMove<N>(pointer)` | Save the `N`-th (0-based) argument to `*pointer` by move-assignment. |
|
||||||
| `SaveArgPointee<N>(pointer)` | Save the value pointed to by the `N`-th (0-based) argument to `*pointer`. |
|
| `SaveArgPointee<N>(pointer)` | Save the value pointed to by the `N`-th (0-based) argument to `*pointer`. |
|
||||||
| `SetArgReferee<N>(value)` | Assign `value` to the variable referenced by the `N`-th (0-based) argument. |
|
| `SetArgReferee<N>(value)` | Assign `value` to the variable referenced by the `N`-th (0-based) argument. |
|
||||||
| `SetArgPointee<N>(value)` | Assign `value` to the variable pointed by the `N`-th (0-based) argument. |
|
| `SetArgPointee<N>(value)` | Assign `value` to the variable pointed by the `N`-th (0-based) argument. |
|
||||||
|
@ -171,6 +171,11 @@ messages, you can use:
|
|||||||
| `Property(&class::property, m)` | `argument.property()` (or `argument->property()` when `argument` is a plain pointer) matches matcher `m`, where `argument` is an object of type _class_. The method `property()` must take no argument and be declared as `const`. |
|
| `Property(&class::property, m)` | `argument.property()` (or `argument->property()` when `argument` is a plain pointer) matches matcher `m`, where `argument` is an object of type _class_. The method `property()` must take no argument and be declared as `const`. |
|
||||||
| `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message.
|
| `Property(property_name, &class::property, m)` | The same as the two-parameter version, but provides a better error message.
|
||||||
|
|
||||||
|
{: .callout .warning}
|
||||||
|
Warning: Don't use `Property()` against member functions that you do not own,
|
||||||
|
because taking addresses of functions is fragile and generally not part of the
|
||||||
|
contract of the function.
|
||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
|
|
||||||
* You can use `FieldsAre()` to match any type that supports structured
|
* You can use `FieldsAre()` to match any type that supports structured
|
||||||
@ -189,10 +194,6 @@ messages, you can use:
|
|||||||
EXPECT_THAT(s, FieldsAre(42, "aloha"));
|
EXPECT_THAT(s, FieldsAre(42, "aloha"));
|
||||||
```
|
```
|
||||||
|
|
||||||
* Don't use `Property()` against member functions that you do not own, because
|
|
||||||
taking addresses of functions is fragile and generally not part of the
|
|
||||||
contract of the function.
|
|
||||||
|
|
||||||
## Matching the Result of a Function, Functor, or Callback
|
## Matching the Result of a Function, Functor, or Callback
|
||||||
|
|
||||||
| Matcher | Description |
|
| Matcher | Description |
|
||||||
|
@ -1720,6 +1720,16 @@ struct SaveArgAction {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <size_t k, typename Ptr>
|
||||||
|
struct SaveArgByMoveAction {
|
||||||
|
Ptr pointer;
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
void operator()(Args&&... args) const {
|
||||||
|
*pointer = std::move(std::get<k>(std::tie(args...)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <size_t k, typename Ptr>
|
template <size_t k, typename Ptr>
|
||||||
struct SaveArgPointeeAction {
|
struct SaveArgPointeeAction {
|
||||||
Ptr pointer;
|
Ptr pointer;
|
||||||
@ -2070,6 +2080,13 @@ internal::SaveArgAction<k, Ptr> SaveArg(Ptr pointer) {
|
|||||||
return {pointer};
|
return {pointer};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action SaveArgByMove<k>(pointer) moves the k-th (0-based) argument of the
|
||||||
|
// mock function into *pointer.
|
||||||
|
template <size_t k, typename Ptr>
|
||||||
|
internal::SaveArgByMoveAction<k, Ptr> SaveArgByMove(Ptr pointer) {
|
||||||
|
return {pointer};
|
||||||
|
}
|
||||||
|
|
||||||
// Action SaveArgPointee<k>(pointer) saves the value pointed to
|
// Action SaveArgPointee<k>(pointer) saves the value pointed to
|
||||||
// by the k-th (0-based) argument of the mock function to *pointer.
|
// by the k-th (0-based) argument of the mock function to *pointer.
|
||||||
template <size_t k, typename Ptr>
|
template <size_t k, typename Ptr>
|
||||||
|
@ -4453,6 +4453,10 @@ inline PolymorphicMatcher<internal::FieldMatcher<Class, FieldType>> Field(
|
|||||||
// matches 'matcher'. For example,
|
// matches 'matcher'. For example,
|
||||||
// Property(&Foo::str, StartsWith("hi"))
|
// Property(&Foo::str, StartsWith("hi"))
|
||||||
// matches a Foo object x if and only if x.str() starts with "hi".
|
// matches a Foo object x if and only if x.str() starts with "hi".
|
||||||
|
//
|
||||||
|
// Warning: Don't use `Property()` against member functions that you do not
|
||||||
|
// own, because taking addresses of functions is fragile and generally not part
|
||||||
|
// of the contract of the function.
|
||||||
template <typename Class, typename PropertyType, typename PropertyMatcher>
|
template <typename Class, typename PropertyType, typename PropertyMatcher>
|
||||||
inline PolymorphicMatcher<internal::PropertyMatcher<
|
inline PolymorphicMatcher<internal::PropertyMatcher<
|
||||||
Class, PropertyType, PropertyType (Class::*)() const>>
|
Class, PropertyType, PropertyType (Class::*)() const>>
|
||||||
|
@ -222,8 +222,8 @@ TEST(TypeTraits, IsInvocableRV) {
|
|||||||
// In C++17 and above, where it's guaranteed that functions can return
|
// In C++17 and above, where it's guaranteed that functions can return
|
||||||
// non-moveable objects, everything should work fine for non-moveable rsult
|
// non-moveable objects, everything should work fine for non-moveable rsult
|
||||||
// types too.
|
// types too.
|
||||||
#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
|
// TODO(b/396121064) - Fix this test under MSVC
|
||||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
#ifndef _MSC_VER
|
||||||
{
|
{
|
||||||
struct NonMoveable {
|
struct NonMoveable {
|
||||||
NonMoveable() = default;
|
NonMoveable() = default;
|
||||||
@ -244,7 +244,7 @@ TEST(TypeTraits, IsInvocableRV) {
|
|||||||
static_assert(!internal::is_callable_r<int, Callable>::value);
|
static_assert(!internal::is_callable_r<int, Callable>::value);
|
||||||
static_assert(!internal::is_callable_r<NonMoveable, Callable, int>::value);
|
static_assert(!internal::is_callable_r<NonMoveable, Callable, int>::value);
|
||||||
}
|
}
|
||||||
#endif // C++17 and above
|
#endif // _MSC_VER
|
||||||
|
|
||||||
// Nothing should choke when we try to call other arguments besides directly
|
// Nothing should choke when we try to call other arguments besides directly
|
||||||
// callable objects, but they should not show up as callable.
|
// callable objects, but they should not show up as callable.
|
||||||
|
@ -59,6 +59,7 @@ using testing::Invoke;
|
|||||||
using testing::ReturnArg;
|
using testing::ReturnArg;
|
||||||
using testing::ReturnPointee;
|
using testing::ReturnPointee;
|
||||||
using testing::SaveArg;
|
using testing::SaveArg;
|
||||||
|
using testing::SaveArgByMove;
|
||||||
using testing::SaveArgPointee;
|
using testing::SaveArgPointee;
|
||||||
using testing::SetArgReferee;
|
using testing::SetArgReferee;
|
||||||
using testing::Unused;
|
using testing::Unused;
|
||||||
@ -492,6 +493,34 @@ TEST(SaveArgActionTest, WorksForCompatibleType) {
|
|||||||
EXPECT_EQ('a', result);
|
EXPECT_EQ('a', result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MoveOnly {
|
||||||
|
explicit MoveOnly(int v) : i(v) {}
|
||||||
|
MoveOnly(MoveOnly&& o) {
|
||||||
|
i = o.i;
|
||||||
|
o.i = -1;
|
||||||
|
}
|
||||||
|
MoveOnly& operator=(MoveOnly&& o) {
|
||||||
|
i = o.i;
|
||||||
|
o.i = -1;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(SaveArgByMoveActionTest, WorksForSameType) {
|
||||||
|
MoveOnly result{0};
|
||||||
|
const Action<void(MoveOnly v)> a1 = SaveArgByMove<0>(&result);
|
||||||
|
a1.Perform(std::make_tuple(MoveOnly{5}));
|
||||||
|
EXPECT_EQ(5, result.i);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SaveArgByMoveActionTest, WorksForCompatibleType) {
|
||||||
|
MoveOnly result{0};
|
||||||
|
const Action<void(bool, MoveOnly)> a1 = SaveArgByMove<1>(&result);
|
||||||
|
a1.Perform(std::make_tuple(true, MoveOnly{7}));
|
||||||
|
EXPECT_EQ(7, result.i);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(SaveArgPointeeActionTest, WorksForSameType) {
|
TEST(SaveArgPointeeActionTest, WorksForSameType) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
const int value = 5;
|
const int value = 5;
|
||||||
@ -756,34 +785,34 @@ TEST(InvokeArgumentTest, Functor6) {
|
|||||||
|
|
||||||
// Tests using InvokeArgument with a 7-ary function.
|
// Tests using InvokeArgument with a 7-ary function.
|
||||||
TEST(InvokeArgumentTest, Function7) {
|
TEST(InvokeArgumentTest, Function7) {
|
||||||
Action<std::string(std::string(*)(const char*, const char*, const char*,
|
Action<std::string(std::string (*)(const char*, const char*, const char*,
|
||||||
const char*, const char*, const char*,
|
const char*, const char*, const char*,
|
||||||
const char*))>
|
const char*))>
|
||||||
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7");
|
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7");
|
||||||
EXPECT_EQ("1234567", a.Perform(std::make_tuple(&Concat7)));
|
EXPECT_EQ("1234567", a.Perform(std::make_tuple(&Concat7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests using InvokeArgument with a 8-ary function.
|
// Tests using InvokeArgument with a 8-ary function.
|
||||||
TEST(InvokeArgumentTest, Function8) {
|
TEST(InvokeArgumentTest, Function8) {
|
||||||
Action<std::string(std::string(*)(const char*, const char*, const char*,
|
Action<std::string(std::string (*)(const char*, const char*, const char*,
|
||||||
const char*, const char*, const char*,
|
const char*, const char*, const char*,
|
||||||
const char*, const char*))>
|
const char*, const char*))>
|
||||||
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8");
|
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8");
|
||||||
EXPECT_EQ("12345678", a.Perform(std::make_tuple(&Concat8)));
|
EXPECT_EQ("12345678", a.Perform(std::make_tuple(&Concat8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests using InvokeArgument with a 9-ary function.
|
// Tests using InvokeArgument with a 9-ary function.
|
||||||
TEST(InvokeArgumentTest, Function9) {
|
TEST(InvokeArgumentTest, Function9) {
|
||||||
Action<std::string(std::string(*)(const char*, const char*, const char*,
|
Action<std::string(std::string (*)(const char*, const char*, const char*,
|
||||||
const char*, const char*, const char*,
|
const char*, const char*, const char*,
|
||||||
const char*, const char*, const char*))>
|
const char*, const char*, const char*))>
|
||||||
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9");
|
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9");
|
||||||
EXPECT_EQ("123456789", a.Perform(std::make_tuple(&Concat9)));
|
EXPECT_EQ("123456789", a.Perform(std::make_tuple(&Concat9)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests using InvokeArgument with a 10-ary function.
|
// Tests using InvokeArgument with a 10-ary function.
|
||||||
TEST(InvokeArgumentTest, Function10) {
|
TEST(InvokeArgumentTest, Function10) {
|
||||||
Action<std::string(std::string(*)(
|
Action<std::string(std::string (*)(
|
||||||
const char*, const char*, const char*, const char*, const char*,
|
const char*, const char*, const char*, const char*, const char*,
|
||||||
const char*, const char*, const char*, const char*, const char*))>
|
const char*, const char*, const char*, const char*, const char*))>
|
||||||
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
|
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
|
||||||
|
@ -804,9 +804,8 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
|
|||||||
"to be called at least once");
|
"to be called at least once");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
|
// TODO(b/396121064) - Fix this test under MSVC
|
||||||
GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
|
#ifndef _MSC_VER
|
||||||
|
|
||||||
// It should be possible to return a non-moveable type from a mock action in
|
// It should be possible to return a non-moveable type from a mock action in
|
||||||
// C++17 and above, where it's guaranteed that such a type can be initialized
|
// C++17 and above, where it's guaranteed that such a type can be initialized
|
||||||
// from a prvalue returned from a function.
|
// from a prvalue returned from a function.
|
||||||
@ -847,7 +846,7 @@ TEST(ExpectCallTest, NonMoveableType) {
|
|||||||
EXPECT_EQ(17, mock.AsStdFunction()().x);
|
EXPECT_EQ(17, mock.AsStdFunction()().x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // C++17 and above
|
#endif // _MSC_VER
|
||||||
|
|
||||||
// Tests that the n-th action is taken for the n-th matching
|
// Tests that the n-th action is taken for the n-th matching
|
||||||
// invocation.
|
// invocation.
|
||||||
|
@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
|
|||||||
with
|
with
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/google/googletest.git -b v1.15.2
|
git clone https://github.com/google/googletest.git -b v1.16.0
|
||||||
cd googletest # Main directory of the cloned repository.
|
cd googletest # Main directory of the cloned repository.
|
||||||
mkdir build # Create a directory to hold the build output.
|
mkdir build # Create a directory to hold the build output.
|
||||||
cd build
|
cd build
|
||||||
|
@ -195,7 +195,7 @@ function(cxx_library_with_type name type cxx_flags)
|
|||||||
target_link_libraries(${name} PUBLIC Threads::Threads)
|
target_link_libraries(${name} PUBLIC Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_features(${name} PUBLIC cxx_std_14)
|
target_compile_features(${name} PUBLIC cxx_std_17)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -275,8 +275,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(GTEST_INTERNAL_CPLUSPLUS_LANG) || \
|
#if !defined(GTEST_INTERNAL_CPLUSPLUS_LANG) || \
|
||||||
GTEST_INTERNAL_CPLUSPLUS_LANG < 201402L
|
GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
|
||||||
#error C++ versions less than C++14 are not supported.
|
#error C++ versions less than C++17 are not supported.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MSVC >= 19.11 (VS 2017 Update 3) supports __has_include.
|
// MSVC >= 19.11 (VS 2017 Update 3) supports __has_include.
|
||||||
|
@ -121,6 +121,9 @@ class UnprintableTemplateInGlobal {
|
|||||||
// A user-defined streamable type in the global namespace.
|
// A user-defined streamable type in the global namespace.
|
||||||
class StreamableInGlobal {
|
class StreamableInGlobal {
|
||||||
public:
|
public:
|
||||||
|
StreamableInGlobal() = default;
|
||||||
|
StreamableInGlobal(const StreamableInGlobal&) = default;
|
||||||
|
StreamableInGlobal& operator=(const StreamableInGlobal&) = default;
|
||||||
virtual ~StreamableInGlobal() = default;
|
virtual ~StreamableInGlobal() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -572,6 +575,8 @@ TEST(PrintU8StringTest, Null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tests that u8 strings are escaped properly.
|
// Tests that u8 strings are escaped properly.
|
||||||
|
// TODO(b/396121064) - Fix this test under MSVC
|
||||||
|
#ifndef _MSC_VER
|
||||||
TEST(PrintU8StringTest, EscapesProperly) {
|
TEST(PrintU8StringTest, EscapesProperly) {
|
||||||
const char8_t* p = u8"'\"?\\\a\b\f\n\r\t\v\x7F\xFF hello 世界";
|
const char8_t* p = u8"'\"?\\\a\b\f\n\r\t\v\x7F\xFF hello 世界";
|
||||||
EXPECT_EQ(PrintPointer(p) +
|
EXPECT_EQ(PrintPointer(p) +
|
||||||
@ -579,7 +584,8 @@ TEST(PrintU8StringTest, EscapesProperly) {
|
|||||||
"hello \\xE4\\xB8\\x96\\xE7\\x95\\x8C\"",
|
"hello \\xE4\\xB8\\x96\\xE7\\x95\\x8C\"",
|
||||||
Print(p));
|
Print(p));
|
||||||
}
|
}
|
||||||
#endif
|
#endif // _MSC_VER
|
||||||
|
#endif // __cpp_lib_char8_t
|
||||||
|
|
||||||
// const char16_t*.
|
// const char16_t*.
|
||||||
TEST(PrintU16StringTest, Const) {
|
TEST(PrintU16StringTest, Const) {
|
||||||
|
@ -31,14 +31,14 @@
|
|||||||
|
|
||||||
class SetupFailTest : public ::testing::Test {
|
class SetupFailTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestSuite() { ASSERT_EQ("", "SET_UP_FAIL"); }
|
static void SetUpTestSuite() { ASSERT_STREQ("", "SET_UP_FAIL"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(SetupFailTest, NoopPassingTest) {}
|
TEST_F(SetupFailTest, NoopPassingTest) {}
|
||||||
|
|
||||||
class TearDownFailTest : public ::testing::Test {
|
class TearDownFailTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static void TearDownTestSuite() { ASSERT_EQ("", "TEAR_DOWN_FAIL"); }
|
static void TearDownTestSuite() { ASSERT_STREQ("", "TEAR_DOWN_FAIL"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(TearDownFailTest, NoopPassingTest) {}
|
TEST_F(TearDownFailTest, NoopPassingTest) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user