You need to sign in or sign up before continuing.
Commit 5d96565c authored by Gaspard Petit's avatar Gaspard Petit
Browse files

Merge branch 'master' into support_xboxone

parents 8b491162 23015249
...@@ -129,7 +129,7 @@ AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"], ...@@ -129,7 +129,7 @@ AS_IF([test "x${HAVE_BUILT_GTEST}" = "xyes"],
GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags` GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
GTEST_LIBS=`${GTEST_CONFIG} --libs` GTEST_LIBS=`${GTEST_CONFIG} --libs`
GTEST_VERSION=`${GTEST_CONFIG} --version`], GTEST_VERSION=`${GTEST_CONFIG} --version`],
[AC_CONFIG_SUBDIRS([../googletest]) [
# GTEST_CONFIG needs to be executable both in a Makefile environment and # GTEST_CONFIG needs to be executable both in a Makefile environment and
# in a shell script environment, so resolve an absolute path for it here. # in a shell script environment, so resolve an absolute path for it here.
GTEST_CONFIG="`pwd -P`/../googletest/scripts/gtest-config" GTEST_CONFIG="`pwd -P`/../googletest/scripts/gtest-config"
......
...@@ -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
......
If you are interested in understanding the internals of Google Mock,
building from source, or contributing ideas or modifications to the
project, then this document is for you.
# Introduction #
First, let's give you some background of the project.
## Licensing ##
All Google Mock source and pre-built packages are provided under the [New BSD License](http://www.opensource.org/licenses/bsd-license.php).
## The Google Mock Community ##
The Google Mock community exists primarily through the [discussion group](http://groups.google.com/group/googlemock), the
[issue tracker](https://github.com/google/googletest/issues) and, to a lesser extent, the [source control repository](../). You are definitely encouraged to contribute to the
discussion and you can also help us to keep the effectiveness of the
group high by following and promoting the guidelines listed here.
### Please Be Friendly ###
Showing courtesy and respect to others is a vital part of the Google
culture, and we strongly encourage everyone participating in Google
Mock development to join us in accepting nothing less. Of course,
being courteous is not the same as failing to constructively disagree
with each other, but it does mean that we should be respectful of each
other when enumerating the 42 technical reasons that a particular
proposal may not be the best choice. There's never a reason to be
antagonistic or dismissive toward anyone who is sincerely trying to
contribute to a discussion.
Sure, C++ testing is serious business and all that, but it's also
a lot of fun. Let's keep it that way. Let's strive to be one of the
friendliest communities in all of open source.
### Where to Discuss Google Mock ###
As always, discuss Google Mock in the official [Google C++ Mocking Framework discussion group](http://groups.google.com/group/googlemock). You don't have to actually submit
code in order to sign up. Your participation itself is a valuable
contribution.
# Working with the Code #
If you want to get your hands dirty with the code inside Google Mock,
this is the section for you.
## Checking Out the Source from Subversion ##
Checking out the Google Mock source is most useful if you plan to
tweak it yourself. You check out the source for Google Mock using a
[Subversion](http://subversion.tigris.org/) client as you would for any
other project hosted on Google Code. Please see the instruction on
the [source code access page](../) for how to do it.
## Compiling from Source ##
Once you check out the code, you can find instructions on how to
compile it in the [README](../README.md) file.
## Testing ##
A mocking framework is of no good if itself is not thoroughly tested.
Tests should be written for any new code, and changes should be
verified to not break existing tests before they are submitted for
review. To perform the tests, follow the instructions in [README](../README.md) and
verify that there are no failures.
# Contributing Code #
We are excited that Google Mock is now open source, and hope to get
great patches from the community. Before you fire up your favorite IDE
and begin hammering away at that new feature, though, please take the
time to read this section and understand the process. While it seems
rigorous, we want to keep a high standard of quality in the code
base.
## Contributor License Agreements ##
You must sign a Contributor License Agreement (CLA) before we can
accept any code. The CLA protects you and us.
* If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).
* If you work for a company that wants to allow you to contribute your work to Google Mock, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it.
## Coding Style ##
To keep the source consistent, readable, diffable and easy to merge,
we use a fairly rigid coding style, as defined by the [google-styleguide](https://github.com/google/styleguide) project. All patches will be expected
to conform to the style outlined [here](https://google.github.io/styleguide/cppguide.html).
## Submitting Patches ##
Please do submit code. Here's what you need to do:
1. Normally you should make your change against the SVN trunk instead of a branch or a tag, as the latter two are for release control and should be treated mostly as read-only.
1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the [Google Mock issue tracker](https://github.com/google/googletest/issues). Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please create one.
1. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being duplicated and communicating your plan early also generally leads to better patches.
1. Ensure that your code adheres to the [Google Mock source code style](#Coding_Style.md).
1. Ensure that there are unit tests for your code.
1. Sign a Contributor License Agreement.
1. Create a patch file using `svn diff`.
1. We use [Rietveld](http://codereview.appspot.com/) to do web-based code reviews. You can read about the tool [here](https://github.com/rietveld-codereview/rietveld/wiki). When you are ready, upload your patch via Rietveld and notify `googlemock@googlegroups.com` to review it. There are several ways to upload the patch. We recommend using the [upload\_gmock.py](../scripts/upload_gmock.py) script, which you can find in the `scripts/` folder in the SVN trunk.
## Google Mock Committers ##
The current members of the Google Mock engineering team are the only
committers at present. In the great tradition of eating one's own
dogfood, we will be requiring each new Google Mock engineering team
member to earn the right to become a committer by following the
procedures in this document, writing consistently great code, and
demonstrating repeatedly that he or she truly gets the zen of Google
Mock.
# Release Process #
We follow the typical release process for Subversion-based projects:
1. A release branch named `release-X.Y` is created.
1. Bugs are fixed and features are added in trunk; those individual patches are merged into the release branch until it's stable.
1. An individual point release (the `Z` in `X.Y.Z`) is made by creating a tag from the branch.
1. Repeat steps 2 and 3 throughout one release cycle (as determined by features or time).
1. Go back to step 1 to create another release branch and so on.
---
This page is based on the [Making GWT Better](http://code.google.com/webtoolkit/makinggwtbetter.html) guide from the [Google Web Toolkit](http://code.google.com/webtoolkit/) project. Except as otherwise [noted](http://code.google.com/policies.html#restrictions), the content of this page is licensed under the [Creative Commons Attribution 2.5 License](http://creativecommons.org/licenses/by/2.5/).
...@@ -11,5 +11,5 @@ the respective git branch/tag).** ...@@ -11,5 +11,5 @@ the respective git branch/tag).**
To contribute code to Google Mock, read: To contribute code to Google Mock, read:
* [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. * [CONTRIBUTING](../CONTRIBUTING.md) -- read this _before_ writing your first patch.
* [Pump Manual](../../googletest/docs/PumpManual.md) -- how we generate some of Google Mock's source files. * [Pump Manual](../../googletest/docs/PumpManual.md) -- how we generate some of Google Mock's source files.
...@@ -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(\
......
...@@ -3615,6 +3615,10 @@ BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond( ...@@ -3615,6 +3615,10 @@ BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(
return BoundSecondMatcher<Tuple2Matcher, Second>(tm, second); return BoundSecondMatcher<Tuple2Matcher, Second>(tm, second);
} }
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string. This function is exported for testing.
GTEST_API_ string JoinAsTuple(const Strings& fields);
// Returns the description for a matcher defined using the MATCHER*() // Returns the description for a matcher defined using the MATCHER*()
// macro where the user-supplied description string is "", if // macro where the user-supplied description string is "", if
// 'negation' is false; otherwise returns the description of the // 'negation' is false; otherwise returns the description of the
......
...@@ -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.
...@@ -508,7 +508,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() ...@@ -508,7 +508,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
return expectations_met; return expectations_met;
} }
CallReaction intToCallReaction(int mock_behavior) { static CallReaction intToCallReaction(int mock_behavior) {
if (mock_behavior >= kAllow && mock_behavior <= kFail) { if (mock_behavior >= kAllow && mock_behavior <= kFail) {
return static_cast<internal::CallReaction>(mock_behavior); return static_cast<internal::CallReaction>(mock_behavior);
} }
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
# #
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock # Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
licenses(["notice"])
""" gmock own tests """ """ gmock own tests """
cc_test( cc_test(
...@@ -43,7 +45,8 @@ cc_test( ...@@ -43,7 +45,8 @@ cc_test(
], ],
), ),
linkopts = select({ linkopts = select({
"//:win": [], "//:windows": [],
"//:windows_msvc": [],
"//conditions:default": [ "//conditions:default": [
"-pthread", "-pthread",
], ],
......
...@@ -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()))));
} }
......
...@@ -44,15 +44,7 @@ ...@@ -44,15 +44,7 @@
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN #if GTEST_OS_CYGWIN
# include <sys/types.h> // For ssize_t. NOLINT # include <sys/types.h> // For ssize_t. NOLINT
......
...@@ -58,11 +58,12 @@ ...@@ -58,11 +58,12 @@
# include <forward_list> // NOLINT # include <forward_list> // NOLINT
#endif #endif
namespace testing { // 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 internal { namespace testing {
GTEST_API_ string JoinAsTuple(const Strings& fields);
} // namespace internal
namespace gmock_matchers_test { namespace gmock_matchers_test {
...@@ -3931,8 +3932,11 @@ TEST(ResultOfTest, WorksForFunctionReferences) { ...@@ -3931,8 +3932,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)
...@@ -72,11 +74,8 @@ config_compiler_and_linker() # Defined in internal_utils.cmake. ...@@ -72,11 +74,8 @@ config_compiler_and_linker() # Defined in internal_utils.cmake.
# Where Google Test's .h files can be found. # Where Google Test's .h files can be found.
include_directories( 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
...@@ -84,10 +83,12 @@ link_directories(${gtest_BINARY_DIR}/src) ...@@ -84,10 +83,12 @@ link_directories(${gtest_BINARY_DIR}/src)
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple. # <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10 # VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
# VS 2013 12 1800 std::tr1::tuple # VS 2013 12 1800 std::tr1::tuple
# VS 2015 14 1900 std::tuple
# VS 2017 15 >= 1910 std::tuple
if (MSVC AND MSVC_VERSION EQUAL 1700) if (MSVC AND MSVC_VERSION EQUAL 1700)
add_definitions(/D _VARIADIC_MAX=10) add_definitions(/D _VARIADIC_MAX=10)
endif() endif()
######################################################################## ########################################################################
# #
# Defines the gtest & gtest_main libraries. User tests should link # Defines the gtest & gtest_main libraries. User tests should link
...@@ -104,8 +105,8 @@ target_link_libraries(gtest_main gtest) ...@@ -104,8 +105,8 @@ target_link_libraries(gtest_main gtest)
# to the targets for when we are part of a parent build (ie being pulled # to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build). # in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
target_include_directories(gtest INTERFACE "${gtest_SOURCE_DIR}/include") target_include_directories(gtest SYSTEM INTERFACE "${gtest_SOURCE_DIR}/include")
target_include_directories(gtest_main INTERFACE "${gtest_SOURCE_DIR}/include") target_include_directories(gtest_main SYSTEM INTERFACE "${gtest_SOURCE_DIR}/include")
endif() endif()
######################################################################## ########################################################################
...@@ -113,11 +114,11 @@ endif() ...@@ -113,11 +114,11 @@ endif()
# Install rules # Install rules
if(INSTALL_GTEST) if(INSTALL_GTEST)
install(TARGETS gtest gtest_main install(TARGETS gtest gtest_main
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(DIRECTORY ${gtest_SOURCE_DIR}/include/gtest install(DIRECTORY "${gtest_SOURCE_DIR}/include/gtest"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# configure and install pkgconfig files # configure and install pkgconfig files
configure_file( configure_file(
......
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