Unverified Commit 4ba3803f authored by Tanzinul Islam's avatar Tanzinul Islam Committed by GitHub
Browse files

Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116

parents 78b1ff07 d175c8bf
...@@ -9,4 +9,16 @@ bazel-googletest ...@@ -9,4 +9,16 @@ bazel-googletest
bazel-out bazel-out
bazel-testlogs bazel-testlogs
# python # python
*.pyc *.pyc
\ No newline at end of file
# Visual Studio files
*.sdf
*.opensdf
*.VC.opendb
*.suo
*.user
_ReSharper.Caches/
Win32-Debug/
Win32-Release/
x64-Debug/
x64-Release/
...@@ -7,7 +7,11 @@ install: ...@@ -7,7 +7,11 @@ install:
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available. # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
# /usr/bin/clang is 3.4, lets override with modern one. # /usr/bin/clang is 3.4, lets override with modern one.
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi
# ccache on OS X needs installation first
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
# reset ccache statistics
- ccache --zero-stats
- echo ${PATH} - echo ${PATH}
- echo ${CXX} - echo ${CXX}
- ${CXX} --version - ${CXX} --version
...@@ -22,22 +26,24 @@ addons: ...@@ -22,22 +26,24 @@ addons:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7 - llvm-toolchain-precise-3.7
packages: packages:
- gcc-4.9
- g++-4.9 - g++-4.9
- clang-3.7 - clang-3.7
- valgrind
os: os:
- linux - linux
- osx - osx
language: cpp language: cpp
cache: ccache
before_cache:
# print statistics before uploading new cache
- ccache --show-stats
compiler: compiler:
- gcc - gcc
- clang - clang
script: ./travis.sh script: ./travis.sh
env: env:
matrix: matrix:
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 - BUILD_TYPE=Debug VERBOSE=1
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 - BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
notifications: notifications:
email: false email: false
sudo: false sudo: false
...@@ -4,6 +4,14 @@ os: Visual Studio 2015 ...@@ -4,6 +4,14 @@ os: Visual Studio 2015
environment: environment:
matrix: matrix:
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017 Win64"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- compiler: msvc-14-seh - compiler: msvc-14-seh
generator: "Visual Studio 14 2015" generator: "Visual Studio 14 2015"
......
...@@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros ...@@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros
described in the previous two sections and supplying the calling described in the previous two sections and supplying the calling
convention as the first argument to the macro. For example, convention as the first argument to the macro. For example,
``` ```
MOCK_METHOD_1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n)); MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n));
MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y)); MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y));
``` ```
where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows. where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows.
......
...@@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock ...@@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock
will print a warning about the "uninteresting call". The rationale is: will print a warning about the "uninteresting call". The rationale is:
* New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called. * New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called.
* However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, he can add an `EXPECT_CALL()` to suppress the warning. * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, they can add an `EXPECT_CALL()` to suppress the warning.
However, sometimes you may want to suppress all "uninteresting call" However, sometimes you may want to suppress all "uninteresting call"
warnings, while sometimes you may want the opposite, i.e. to treat all warnings, while sometimes you may want the opposite, i.e. to treat all
......
...@@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati ...@@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati
This syntax is designed to make an expectation read like English. For example, you can probably guess that This syntax is designed to make an expectation read like English. For example, you can probably guess that
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetX()) EXPECT_CALL(turtle, GetX())
.Times(5) .Times(5)
.WillOnce(Return(100)) .WillOnce(Return(100))
...@@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_)); ...@@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_));
A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher: A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher:
``` ```
using ::testing::Ge;... using ::testing::Ge;
...
EXPECT_CALL(turtle, Forward(Ge(100))); EXPECT_CALL(turtle, Forward(Ge(100)));
``` ```
...@@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th ...@@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th
Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example, Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example,
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetX()) EXPECT_CALL(turtle, GetX())
.WillOnce(Return(100)) .WillOnce(Return(100))
.WillOnce(Return(200)) .WillOnce(Return(200))
...@@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX()) ...@@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX())
This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively. This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively.
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetY()) EXPECT_CALL(turtle, GetY())
.WillOnce(Return(100)) .WillOnce(Return(100))
.WillOnce(Return(200)) .WillOnce(Return(200))
...@@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will ...@@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will
Time for another quiz! What do you think the following means? Time for another quiz! What do you think the following means?
``` ```
using ::testing::Return;... using ::testing::Return;
...
EXPECT_CALL(turtle, GetY()) EXPECT_CALL(turtle, GetY())
.Times(4) .Times(4)
.WillOnce(Return(100)); .WillOnce(Return(100));
...@@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali ...@@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali
By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example: By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example:
``` ```
using ::testing::_;... using ::testing::_;
...
EXPECT_CALL(turtle, Forward(_)); // #1 EXPECT_CALL(turtle, Forward(_)); // #1
EXPECT_CALL(turtle, Forward(10)) // #2 EXPECT_CALL(turtle, Forward(10)) // #2
.Times(2); .Times(2);
...@@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h ...@@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h
Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy: Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy:
``` ```
using ::testing::InSequence;... using ::testing::InSequence;
...
TEST(FooTest, DrawsLineSegment) { TEST(FooTest, DrawsLineSegment) {
... ...
{ {
...@@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H ...@@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H
After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!): After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!):
``` ```
using ::testing::_;... using ::testing::_;
...
EXPECT_CALL(turtle, GoTo(_, _)) // #1 EXPECT_CALL(turtle, GoTo(_, _)) // #1
.Times(AnyNumber()); .Times(AnyNumber());
EXPECT_CALL(turtle, GoTo(0, 0)) // #2 EXPECT_CALL(turtle, GoTo(0, 0)) // #2
......
...@@ -240,7 +240,7 @@ You cannot mock a variadic function (i.e. a function taking ellipsis ...@@ -240,7 +240,7 @@ You cannot mock a variadic function (i.e. a function taking ellipsis
The problem is that in general, there is _no way_ for a mock object to The problem is that in general, there is _no way_ for a mock object to
know how many arguments are passed to the variadic method, and what know how many arguments are passed to the variadic method, and what
the arguments' types are. Only the _author of the base class_ knows the arguments' types are. Only the _author of the base class_ knows
the protocol, and we cannot look into his head. the protocol, and we cannot look into their head.
Therefore, to mock such a function, the _user_ must teach the mock Therefore, to mock such a function, the _user_ must teach the mock
object how to figure out the number of arguments and their types. One object how to figure out the number of arguments and their types. One
......
...@@ -1376,7 +1376,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1376,7 +1376,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
// ================ // ================
// //
// To learn more about using these macros, please search for 'MATCHER' // To learn more about using these macros, please search for 'MATCHER'
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md // on https://github.com/google/googletest/blob/master/googlemock/docs/
// CookBook.md
#define MATCHER(name, description)\ #define MATCHER(name, description)\
class name##Matcher {\ class name##Matcher {\
...@@ -1397,8 +1398,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1397,8 +1398,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1446,8 +1448,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1446,8 +1448,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1499,8 +1502,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1499,8 +1502,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1557,8 +1561,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1557,8 +1561,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1620,8 +1625,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1620,8 +1625,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1691,8 +1697,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1691,8 +1697,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1765,8 +1772,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1765,8 +1772,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1843,8 +1851,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1843,8 +1851,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -1928,8 +1937,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -1928,8 +1937,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -2019,8 +2029,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -2019,8 +2029,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
...@@ -2115,8 +2126,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { ...@@ -2115,8 +2126,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
......
...@@ -639,8 +639,9 @@ $var param_field_decls2 = [[$for j ...@@ -639,8 +639,9 @@ $var param_field_decls2 = [[$for j
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
......
...@@ -1774,7 +1774,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { ...@@ -1774,7 +1774,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// There is no generally useful and implementable semantics of // There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error. // copying a mock object, so copying a mock is usually a user error.
// Thus we disallow copying function mockers. If the user really // Thus we disallow copying function mockers. If the user really
// wants to copy a mock object, he should implement his own copy // wants to copy a mock object, they should implement their own copy
// operation, for example: // operation, for example:
// //
// class MockFoo : public Foo { // class MockFoo : public Foo {
......
...@@ -71,7 +71,7 @@ GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) { ...@@ -71,7 +71,7 @@ GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) {
} }
// This class reports Google Mock failures as Google Test failures. A // This class reports Google Mock failures as Google Test failures. A
// user can define another class in a similar fashion if he intends to // user can define another class in a similar fashion if they intend to
// use Google Mock with a testing framework other than Google Test. // use Google Mock with a testing framework other than Google Test.
class GoogleTestFailureReporter : public FailureReporterInterface { class GoogleTestFailureReporter : public FailureReporterInterface {
public: public:
......
...@@ -353,10 +353,10 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args) ...@@ -353,10 +353,10 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args)
// the behavior of ReportUninterestingCall(). // the behavior of ReportUninterestingCall().
const bool need_to_report_uninteresting_call = const bool need_to_report_uninteresting_call =
// If the user allows this uninteresting call, we print it // If the user allows this uninteresting call, we print it
// only when he wants informational messages. // only when they want informational messages.
reaction == kAllow ? LogIsVisible(kInfo) : reaction == kAllow ? LogIsVisible(kInfo) :
// If the user wants this to be a warning, we print it only // If the user wants this to be a warning, we print it only
// when he wants to see warnings. // when they want to see warnings.
reaction == kWarn ? LogIsVisible(kWarning) : reaction == kWarn ? LogIsVisible(kWarning) :
// Otherwise, the user wants this to be an error, and we // Otherwise, the user wants this to be an error, and we
// should always print detailed information in the error. // should always print detailed information in the error.
......
...@@ -391,7 +391,7 @@ TEST(ExactlyTest, HasCorrectBounds) { ...@@ -391,7 +391,7 @@ TEST(ExactlyTest, HasCorrectBounds) {
EXPECT_EQ(3, c.ConservativeUpperBound()); EXPECT_EQ(3, c.ConservativeUpperBound());
} }
// Tests that a user can make his own cardinality by implementing // Tests that a user can make their own cardinality by implementing
// CardinalityInterface and calling MakeCardinality(). // CardinalityInterface and calling MakeCardinality().
class EvenCardinality : public CardinalityInterface { class EvenCardinality : public CardinalityInterface {
......
...@@ -120,7 +120,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) { ...@@ -120,7 +120,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) {
} }
TEST(ArgsTest, AcceptsTwoTemplateArgs) { TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt())));
...@@ -128,13 +128,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) { ...@@ -128,13 +128,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
} }
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
} }
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
} }
...@@ -159,7 +159,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) { ...@@ -159,7 +159,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
} }
TEST(ArgsTest, CanBeNested) { TEST(ArgsTest, CanBeNested) {
const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT const tuple<short, int, long, int> t(static_cast<short>(4), 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
} }
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -58,6 +58,11 @@ ...@@ -58,6 +58,11 @@
# include <forward_list> // NOLINT # include <forward_list> // NOLINT
#endif #endif
// Disable MSVC2015 warning for std::pair: "decorated name length exceeded, name was truncated".
#if defined(_MSC_VER) && (_MSC_VER == 1900)
# pragma warning(disable:4503)
#endif
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -3931,8 +3936,11 @@ TEST(ResultOfTest, WorksForFunctionReferences) { ...@@ -3931,8 +3936,11 @@ TEST(ResultOfTest, WorksForFunctionReferences) {
// Tests that ResultOf(f, ...) compiles and works as expected when f is a // Tests that ResultOf(f, ...) compiles and works as expected when f is a
// function object. // function object.
struct Functor : public ::std::unary_function<int, std::string> { struct Functor {
result_type operator()(argument_type input) const { typedef std::string result_type;
typedef int argument_type;
std::string operator()(int input) const {
return IntToStringFunction(input); return IntToStringFunction(input);
} }
}; };
......
...@@ -2682,7 +2682,7 @@ TEST(SynchronizationTest, CanCallMockMethodInAction) { ...@@ -2682,7 +2682,7 @@ TEST(SynchronizationTest, CanCallMockMethodInAction) {
} // namespace } // namespace
// Allows the user to define his own main and then invoke gmock_main // Allows the user to define their own main and then invoke gmock_main
// from it. This might be necessary on some platforms which require // from it. This might be necessary on some platforms which require
// specific setup and teardown. // specific setup and teardown.
#if GMOCK_RENAME_MAIN #if GMOCK_RENAME_MAIN
......
...@@ -27,6 +27,8 @@ option( ...@@ -27,6 +27,8 @@ option(
"Build gtest with internal symbols hidden in shared libraries." "Build gtest with internal symbols hidden in shared libraries."
OFF) OFF)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a postfix.")
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include(cmake/hermetic_build.cmake OPTIONAL) include(cmake/hermetic_build.cmake OPTIONAL)
...@@ -75,9 +77,6 @@ include_directories( ...@@ -75,9 +77,6 @@ include_directories(
${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR}) ${gtest_SOURCE_DIR})
# Where Google Test's libraries can be found.
link_directories(${gtest_BINARY_DIR}/src)
# Summary of tuple support for Microsoft Visual Studio: # Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support # Compiler version(MS) version(cmake) Support
# ---------- ----------- -------------- ----------------------------- # ---------- ----------- -------------- -----------------------------
......
...@@ -161,7 +161,8 @@ Existing build's `CMakeLists.txt`: ...@@ -161,7 +161,8 @@ Existing build's `CMakeLists.txt`:
# Add googletest directly to our build. This defines # Add googletest directly to our build. This defines
# the gtest and gtest_main targets. # the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build) ${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path # The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or # dependencies automatically when using CMake 2.8.11 or
...@@ -182,6 +183,17 @@ technique is discussed in more detail in ...@@ -182,6 +183,17 @@ technique is discussed in more detail in
which also contains a link to a fully generalized implementation which also contains a link to a fully generalized implementation
of the technique. of the technique.
##### Visual Studio Dynamic vs Static Runtimes #####
By default, new Visual Studio projects link the C runtimes dynamically
but Google Test links them statically.
This will generate an error that looks something like the following:
gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
Google Test already has a CMake option for this: `gtest_force_shared_crt`
Enabling this option will make gtest link the runtimes dynamically too,
and match the project in which it is included.
### Legacy Build Scripts ### ### Legacy Build Scripts ###
......
...@@ -87,10 +87,6 @@ macro(config_compiler_and_linker) ...@@ -87,10 +87,6 @@ macro(config_compiler_and_linker)
# http://stackoverflow.com/questions/3232669 explains the issue. # http://stackoverflow.com/questions/3232669 explains the issue.
set(cxx_base_flags "${cxx_base_flags} -wd4702") set(cxx_base_flags "${cxx_base_flags} -wd4702")
endif() endif()
if (NOT (MSVC_VERSION GREATER 1900)) # 1900 is Visual Studio 2015
# BigObj required for tests.
set(cxx_base_flags "${cxx_base_flags} -bigobj")
endif()
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32") set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN") set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
...@@ -98,7 +94,7 @@ macro(config_compiler_and_linker) ...@@ -98,7 +94,7 @@ macro(config_compiler_and_linker)
set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0") set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
set(cxx_no_rtti_flags "-GR-") set(cxx_no_rtti_flags "-GR-")
elseif (CMAKE_COMPILER_IS_GNUCXX) elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow") set(cxx_base_flags "-Wall -Wshadow -Werror")
set(cxx_exception_flags "-fexceptions") set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions") set(cxx_no_exception_flags "-fno-exceptions")
# Until version 4.3.2, GCC doesn't define a macro to indicate # Until version 4.3.2, GCC doesn't define a macro to indicate
...@@ -187,6 +183,10 @@ endfunction() ...@@ -187,6 +183,10 @@ endfunction()
# is built from the given source files with the given compiler flags. # is built from the given source files with the given compiler flags.
function(cxx_executable_with_flags name cxx_flags libs) function(cxx_executable_with_flags name cxx_flags libs)
add_executable(${name} ${ARGN}) add_executable(${name} ${ARGN})
if (MSVC AND (NOT (MSVC_VERSION LESS 1700))) # 1700 is Visual Studio 2012.
# BigObj required for tests.
set(cxx_flags "${cxx_flags} -bigobj")
endif()
if (cxx_flags) if (cxx_flags)
set_target_properties(${name} set_target_properties(${name}
PROPERTIES PROPERTIES
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment