Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
d4f77c1e
Unverified
Commit
d4f77c1e
authored
Feb 27, 2018
by
Gennadiy Civil
Committed by
GitHub
Feb 27, 2018
Browse files
Merge branch 'master' into win-libcxx2
parents
3498a1ac
ac34e6c9
Changes
52
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
226 additions
and
101 deletions
+226
-101
BUILD.bazel
BUILD.bazel
+21
-0
WORKSPACE
WORKSPACE
+7
-0
appveyor.yml
appveyor.yml
+1
-0
ci/build-linux-bazel.sh
ci/build-linux-bazel.sh
+1
-0
googlemock/docs/CookBook.md
googlemock/docs/CookBook.md
+3
-3
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+3
-8
googlemock/include/gmock/gmock-more-matchers.h
googlemock/include/gmock/gmock-more-matchers.h
+16
-0
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+4
-5
googlemock/include/gmock/gmock.h
googlemock/include/gmock/gmock.h
+1
-1
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
...k/include/gmock/internal/gmock-generated-internal-utils.h
+16
-9
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+36
-3
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+7
-11
googlemock/scripts/generator/cpp/ast.py
googlemock/scripts/generator/cpp/ast.py
+3
-3
googlemock/src/gmock-internal-utils.cc
googlemock/src/gmock-internal-utils.cc
+19
-0
googlemock/src/gmock-matchers.cc
googlemock/src/gmock-matchers.cc
+0
-19
googlemock/test/BUILD.bazel
googlemock/test/BUILD.bazel
+70
-2
googlemock/test/gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+1
-1
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+7
-30
googlemock/test/gmock_output_test.py
googlemock/test/gmock_output_test.py
+8
-5
googlemock/test/gmock_stress_test.cc
googlemock/test/gmock_stress_test.cc
+2
-1
No files found.
BUILD.bazel
View file @
d4f77c1e
...
@@ -46,6 +46,12 @@ config_setting(
...
@@ -46,6 +46,12 @@ config_setting(
values
=
{
"cpu"
:
"x64_windows_msvc"
},
values
=
{
"cpu"
:
"x64_windows_msvc"
},
)
)
config_setting
(
name
=
"has_absl"
,
values
=
{
"define"
:
"absl=1"
},
)
# Google Test including Google Mock
# Google Test including Google Mock
cc_library
(
cc_library
(
name
=
"gtest"
,
name
=
"gtest"
,
...
@@ -88,6 +94,21 @@ cc_library(
...
@@ -88,6 +94,21 @@ cc_library(
"-pthread"
,
"-pthread"
,
],
],
}),
}),
defines
=
select
({
":has_absl"
:
[
"GTEST_HAS_ABSL=1"
,
],
"//conditions:default"
:
[],
}
),
deps
=
select
({
":has_absl"
:
[
"@com_google_absl//absl/types:optional"
,
"@com_google_absl//absl/strings"
],
"//conditions:default"
:
[],
}
)
)
)
cc_library
(
cc_library
(
...
...
WORKSPACE
View file @
d4f77c1e
workspace
(
name
=
"com_google_googletest"
)
workspace
(
name
=
"com_google_googletest"
)
# Abseil
http_archive
(
name
=
"com_google_absl"
,
urls
=
[
"https://github.com/abseil/abseil-cpp/archive/master.zip"
],
strip_prefix
=
"abseil-cpp-master"
,
)
appveyor.yml
View file @
d4f77c1e
...
@@ -15,6 +15,7 @@ environment:
...
@@ -15,6 +15,7 @@ environment:
-
compiler
:
msvc-14-seh
-
compiler
:
msvc-14-seh
generator
:
"
Visual
Studio
14
2015"
generator
:
"
Visual
Studio
14
2015"
enabled_on_pr
:
yes
-
compiler
:
msvc-14-seh
-
compiler
:
msvc-14-seh
generator
:
"
Visual
Studio
14
2015
Win64"
generator
:
"
Visual
Studio
14
2015
Win64"
...
...
ci/build-linux-bazel.sh
View file @
d4f77c1e
...
@@ -33,3 +33,4 @@ set -e
...
@@ -33,3 +33,4 @@ set -e
bazel build
--curses
=
no //...:all
bazel build
--curses
=
no //...:all
bazel
test
--curses
=
no //...:all
bazel
test
--curses
=
no //...:all
bazel
test
--curses
=
no //...:all
--define
absl
=
1
googlemock/docs/CookBook.md
View file @
d4f77c1e
...
@@ -1231,7 +1231,7 @@ that references the implementation object dies, the implementation
...
@@ -1231,7 +1231,7 @@ that references the implementation object dies, the implementation
object will be deleted.
object will be deleted.
Therefore, if you have some complex matcher that you want to use again
Therefore, if you have some complex matcher that you want to use again
and again, there is no need to build it everytime. Just assign it to a
and again, there is no need to build it every
time. Just assign it to a
matcher variable and use that variable repeatedly! For example,
matcher variable and use that variable repeatedly! For example,
```
```
...
@@ -1403,7 +1403,7 @@ edge from node A to node B wherever A must occur before B, we can get
...
@@ -1403,7 +1403,7 @@ edge from node A to node B wherever A must occur before B, we can get
a DAG. We use the term "sequence" to mean a directed path in this
a DAG. We use the term "sequence" to mean a directed path in this
DAG. Now, if we decompose the DAG into sequences, we just need to know
DAG. Now, if we decompose the DAG into sequences, we just need to know
which sequences each
`EXPECT_CALL()`
belongs to in order to be able to
which sequences each
`EXPECT_CALL()`
belongs to in order to be able to
reconstruct the orginal DAG.
reconstruct the or
i
ginal DAG.
So, to specify the partial order on the expectations we need to do two
So, to specify the partial order on the expectations we need to do two
things: first to define some
`Sequence`
objects, and then for each
things: first to define some
`Sequence`
objects, and then for each
...
@@ -2182,7 +2182,7 @@ the implementation object dies, the implementation object will be
...
@@ -2182,7 +2182,7 @@ the implementation object dies, the implementation object will be
deleted.
deleted.
If you have some complex action that you want to use again and again,
If you have some complex action that you want to use again and again,
you may not have to build it from scratch everytime. If the action
you may not have to build it from scratch every
time. If the action
doesn't have an internal state (i.e. if it always does the same thing
doesn't have an internal state (i.e. if it always does the same thing
no matter how many times it has been called), you can assign it to an
no matter how many times it has been called), you can assign it to an
action variable and use that variable repeatedly. For example:
action variable and use that variable repeatedly. For example:
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
d4f77c1e
...
@@ -47,10 +47,9 @@
...
@@ -47,10 +47,9 @@
#include <string>
#include <string>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#if GTEST_HAS_STD_INITIALIZER_LIST_
#if GTEST_HAS_STD_INITIALIZER_LIST_
# include <initializer_list> // NOLINT -- must be after gtest.h
# include <initializer_list> // NOLINT -- must be after gtest.h
...
@@ -1551,7 +1550,7 @@ class BothOfMatcherImpl : public MatcherInterface<T> {
...
@@ -1551,7 +1550,7 @@ class BothOfMatcherImpl : public MatcherInterface<T> {
// MatcherList provides mechanisms for storing a variable number of matchers in
// MatcherList provides mechanisms for storing a variable number of matchers in
// a list structure (ListType) and creating a combining matcher from such a
// a list structure (ListType) and creating a combining matcher from such a
// list.
// list.
// The template is defined recursively using the following template paramters:
// The template is defined recursively using the following template param
e
ters:
// * kSize is the length of the MatcherList.
// * kSize is the length of the MatcherList.
// * Head is the type of the first matcher of the list.
// * Head is the type of the first matcher of the list.
// * Tail denotes the types of the remaining matchers of the list.
// * Tail denotes the types of the remaining matchers of the list.
...
@@ -2380,7 +2379,7 @@ class ResultOfMatcher {
...
@@ -2380,7 +2379,7 @@ class ResultOfMatcher {
private:
private:
// Functors often define operator() as non-const method even though
// Functors often define operator() as non-const method even though
// they are actualy stateless. But we need to use them even when
// they are actual
l
y stateless. But we need to use them even when
// 'this' is a const pointer. It's the user's responsibility not to
// 'this' is a const pointer. It's the user's responsibility not to
// use stateful callables with ResultOf(), which does't guarantee
// use stateful callables with ResultOf(), which does't guarantee
// how many times the callable will be invoked.
// how many times the callable will be invoked.
...
@@ -3615,10 +3614,6 @@ BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(
...
@@ -3615,10 +3614,6 @@ 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
...
...
googlemock/include/gmock/gmock-more-matchers.h
View file @
d4f77c1e
...
@@ -53,6 +53,22 @@ MATCHER(IsEmpty, negation ? "isn't empty" : "is empty") {
...
@@ -53,6 +53,22 @@ MATCHER(IsEmpty, negation ? "isn't empty" : "is empty") {
return
false
;
return
false
;
}
}
// Define a matcher that matches a value that evaluates in boolean
// context to true. Useful for types that define "explicit operator
// bool" operators and so can't be compared for equality with true
// and false.
MATCHER
(
IsTrue
,
negation
?
"is false"
:
"is true"
)
{
return
static_cast
<
bool
>
(
arg
);
}
// Define a matcher that matches a value that evaluates in boolean
// context to false. Useful for types that define "explicit operator
// bool" operators and so can't be compared for equality with true
// and false.
MATCHER
(
IsFalse
,
negation
?
"is true"
:
"is false"
)
{
return
!
static_cast
<
bool
>
(
arg
);
}
}
// namespace testing
}
// namespace testing
#endif // GMOCK_GMOCK_MORE_MATCHERS_H_
#endif // GMOCK_GMOCK_MORE_MATCHERS_H_
googlemock/include/gmock/gmock-spec-builders.h
View file @
d4f77c1e
...
@@ -65,11 +65,6 @@
...
@@ -65,11 +65,6 @@
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <vector>
#include <vector>
#if GTEST_HAS_EXCEPTIONS
# include <stdexcept> // NOLINT
#endif
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
...
@@ -77,6 +72,10 @@
...
@@ -77,6 +72,10 @@
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_HAS_EXCEPTIONS
# include <stdexcept> // NOLINT
#endif
namespace
testing
{
namespace
testing
{
// An abstract handle of an expectation.
// An abstract handle of an expectation.
...
...
googlemock/include/gmock/gmock.h
View file @
d4f77c1e
...
@@ -59,8 +59,8 @@
...
@@ -59,8 +59,8 @@
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-nice-strict.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-nice-strict.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-matchers.h"
#include "gmock/gmock-more-matchers.h"
...
...
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
View file @
d4f77c1e
...
@@ -90,42 +90,48 @@ struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
...
@@ -90,42 +90,48 @@ struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
>
Matcher
<
A4
>
>
type
;
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
>
type
;
Matcher
<
A5
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
typename
A6
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
>
type
;
Matcher
<
A5
>
,
Matcher
<
A6
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
typename
A6
,
typename
A7
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
>
type
;
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
typename
A6
,
typename
A7
,
typename
A8
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
>
type
;
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
>
{
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A9
>
>
type
;
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A9
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
...
@@ -133,8 +139,9 @@ template <typename A1, typename A2, typename A3, typename A4, typename A5,
...
@@ -133,8 +139,9 @@ template <typename A1, typename A2, typename A3, typename A4, typename A5,
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
>
>
{
A10
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A9
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A10
>
>
type
;
Matcher
<
A9
>
,
Matcher
<
A10
>
>
type
;
};
};
// Template struct Function<F>, where F must be a function type, contains
// Template struct Function<F>, where F must be a function type, contains
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
d4f77c1e
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdio.h>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <string>
#include <string>
#include "gmock/internal/gmock-generated-internal-utils.h"
#include "gmock/internal/gmock-generated-internal-utils.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
@@ -49,11 +48,15 @@
...
@@ -49,11 +48,15 @@
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
GTEST_API_
std
::
string
JoinAsTuple
(
const
Strings
&
fields
);
// Converts an identifier name to a space-separated list of lower-case
// Converts an identifier name to a space-separated list of lower-case
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// treated as one word. For example, both "FooBar123" and
// "foo_bar_123" are converted to "foo bar 123".
// "foo_bar_123" are converted to "foo bar 123".
GTEST_API_
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
);
GTEST_API_
std
::
string
ConvertIdentifierNameToWords
(
const
char
*
id_name
);
// PointeeOf<Pointer>::type is the type of a value pointed to by a
// PointeeOf<Pointer>::type is the type of a value pointed to by a
// Pointer, which can be either a smart pointer or a raw pointer. The
// Pointer, which can be either a smart pointer or a raw pointer. The
...
@@ -503,8 +506,38 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
...
@@ -503,8 +506,38 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
template
<
bool
kValue
>
template
<
bool
kValue
>
struct
BooleanConstant
{};
struct
BooleanConstant
{};
// Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to
// reduce code size.
void
IllegalDoDefault
(
const
char
*
file
,
int
line
);
#if GTEST_LANG_CXX11
// Helper types for Apply() below.
template
<
size_t
...
Is
>
struct
int_pack
{
typedef
int_pack
type
;
};
template
<
class
Pack
,
size_t
I
>
struct
append
;
template
<
size_t
...
Is
,
size_t
I
>
struct
append
<
int_pack
<
Is
...
>
,
I
>
:
int_pack
<
Is
...,
I
>
{};
template
<
size_t
C
>
struct
make_int_pack
:
append
<
typename
make_int_pack
<
C
-
1
>::
type
,
C
-
1
>
{};
template
<
>
struct
make_int_pack
<
0
>
:
int_pack
<>
{};
template
<
typename
F
,
typename
Tuple
,
size_t
...
Idx
>
auto
ApplyImpl
(
F
&&
f
,
Tuple
&&
args
,
int_pack
<
Idx
...
>
)
->
decltype
(
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...))
{
return
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...);
}
// Apply the function to a tuple of arguments.
template
<
typename
F
,
typename
Tuple
>
auto
Apply
(
F
&&
f
,
Tuple
&&
args
)
->
decltype
(
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
make_int_pack
<
std
::
tuple_size
<
Tuple
>::
value
>
()))
{
return
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
make_int_pack
<
std
::
tuple_size
<
Tuple
>::
value
>
());
}
#endif
}
// namespace internal
}
// namespace internal
}
// namespace testing
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
googlemock/include/gmock/internal/gmock-port.h
View file @
d4f77c1e
...
@@ -50,15 +50,11 @@
...
@@ -50,15 +50,11 @@
// portability utilities to Google Test's gtest-port.h instead of
// portability utilities to Google Test's gtest-port.h instead of
// here, as Google Mock depends on Google Test. Only add a utility
// here, as Google Mock depends on Google Test. Only add a utility
// here if it's truly specific to Google Mock.
// here if it's truly specific to Google Mock.
#include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gmock/internal/custom/gmock-port.h"
// To avoid conditional compilation everywhere, we make it
// gmock-port.h's responsibility to #include the header implementing
// tr1/tuple. gmock-port.h does this via gtest-port.h, which is
// guaranteed to pull in the tuple header.
// For MS Visual C++, check the compiler version. At least VS 2003 is
// For MS Visual C++, check the compiler version. At least VS 2003 is
// required to compile Google Mock.
// required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1310
#if defined(_MSC_VER) && _MSC_VER < 1310
...
@@ -72,18 +68,18 @@
...
@@ -72,18 +68,18 @@
#if !defined(GMOCK_DECLARE_bool_)
#if !defined(GMOCK_DECLARE_bool_)
// Macros for declaring flags.
// Macros for declaring flags.
#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
#
define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
#define GMOCK_DECLARE_int32_(name) \
#
define GMOCK_DECLARE_int32_(name) \
extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
#define GMOCK_DECLARE_string_(name) \
#
define GMOCK_DECLARE_string_(name) \
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
// Macros for defining flags.
// Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
#
define GMOCK_DEFINE_bool_(name, default_val, doc) \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
#
define GMOCK_DEFINE_int32_(name, default_val, doc) \
GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
#define GMOCK_DEFINE_string_(name, default_val, doc) \
#
define GMOCK_DEFINE_string_(name, default_val, doc) \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
#endif // !defined(GMOCK_DECLARE_bool_)
#endif // !defined(GMOCK_DECLARE_bool_)
...
...
googlemock/scripts/generator/cpp/ast.py
View file @
d4f77c1e
...
@@ -338,7 +338,7 @@ class Class(_GenericDeclaration):
...
@@ -338,7 +338,7 @@ class Class(_GenericDeclaration):
# TODO(nnorwitz): handle namespaces, etc.
# TODO(nnorwitz): handle namespaces, etc.
if
self
.
bases
:
if
self
.
bases
:
for
token_list
in
self
.
bases
:
for
token_list
in
self
.
bases
:
# TODO(nnorwitz): bases are tokens, do name comparis
i
on.
# TODO(nnorwitz): bases are tokens, do name comparison.
for
token
in
token_list
:
for
token
in
token_list
:
if
token
.
name
==
node
.
name
:
if
token
.
name
==
node
.
name
:
return
True
return
True
...
@@ -381,7 +381,7 @@ class Function(_GenericDeclaration):
...
@@ -381,7 +381,7 @@ class Function(_GenericDeclaration):
def
Requires
(
self
,
node
):
def
Requires
(
self
,
node
):
if
self
.
parameters
:
if
self
.
parameters
:
# TODO(nnorwitz): parameters are tokens, do name comparis
i
on.
# TODO(nnorwitz): parameters are tokens, do name comparison.
for
p
in
self
.
parameters
:
for
p
in
self
.
parameters
:
if
p
.
name
==
node
.
name
:
if
p
.
name
==
node
.
name
:
return
True
return
True
...
@@ -858,7 +858,7 @@ class AstBuilder(object):
...
@@ -858,7 +858,7 @@ class AstBuilder(object):
last_token
=
self
.
_GetNextToken
()
last_token
=
self
.
_GetNextToken
()
return
tokens
,
last_token
return
tokens
,
last_token
# TODO(nnorwitz): remove _IgnoreUpTo() it shouldn't be necesary.
# TODO(nnorwitz): remove _IgnoreUpTo() it shouldn't be neces
s
ary.
def
_IgnoreUpTo
(
self
,
token_type
,
token
):
def
_IgnoreUpTo
(
self
,
token_type
,
token
):
unused_tokens
=
self
.
_GetTokensUpTo
(
token_type
,
token
)
unused_tokens
=
self
.
_GetTokensUpTo
(
token_type
,
token
)
...
...
googlemock/src/gmock-internal-utils.cc
View file @
d4f77c1e
...
@@ -47,6 +47,25 @@
...
@@ -47,6 +47,25 @@
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
GTEST_API_
std
::
string
JoinAsTuple
(
const
Strings
&
fields
)
{
switch
(
fields
.
size
())
{
case
0
:
return
""
;
case
1
:
return
fields
[
0
];
default:
std
::
string
result
=
"("
+
fields
[
0
];
for
(
size_t
i
=
1
;
i
<
fields
.
size
();
i
++
)
{
result
+=
", "
;
result
+=
fields
[
i
];
}
result
+=
")"
;
return
result
;
}
}
// Converts an identifier name to a space-separated list of lower-case
// Converts an identifier name to a space-separated list of lower-case
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
// treated as one word. For example, both "FooBar123" and
// treated as one word. For example, both "FooBar123" and
...
...
googlemock/src/gmock-matchers.cc
View file @
d4f77c1e
...
@@ -100,25 +100,6 @@ Matcher<StringPiece>::Matcher(StringPiece s) {
...
@@ -100,25 +100,6 @@ Matcher<StringPiece>::Matcher(StringPiece s) {
namespace
internal
{
namespace
internal
{
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
GTEST_API_
string
JoinAsTuple
(
const
Strings
&
fields
)
{
switch
(
fields
.
size
())
{
case
0
:
return
""
;
case
1
:
return
fields
[
0
];
default:
string
result
=
"("
+
fields
[
0
];
for
(
size_t
i
=
1
;
i
<
fields
.
size
();
i
++
)
{
result
+=
", "
;
result
+=
fields
[
i
];
}
result
+=
")"
;
return
result
;
}
}
// 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
...
...
googlemock/test/BUILD.bazel
View file @
d4f77c1e
# Copyright 2017 Google Inc.
# Copyright 2017 Google Inc.
# All Rights Reserved.
# All Rights Reserved.
#
#
#
#
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# Author: misterg@google.com (Gennadiy Civil)
# Author: misterg@google.com (Gennadiy Civil)
#
#
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
licenses
([
"notice"
])
licenses
([
"notice"
])
...
@@ -53,3 +53,71 @@ cc_test(
...
@@ -53,3 +53,71 @@ cc_test(
}),
}),
deps
=
[
"//:gtest"
],
deps
=
[
"//:gtest"
],
)
)
# Py tests
py_library
(
name
=
"gmock_test_utils"
,
testonly
=
1
,
srcs
=
[
"gmock_test_utils.py"
],
)
cc_binary
(
name
=
"gmock_leak_test_"
,
testonly
=
1
,
srcs
=
[
"gmock_leak_test_.cc"
],
deps
=
[
"//:gtest_main"
,
],
)
py_test
(
name
=
"gmock_leak_test"
,
size
=
"medium"
,
srcs
=
[
"gmock_leak_test.py"
],
data
=
[
":gmock_leak_test_"
,
":gmock_test_utils"
,
],
)
cc_test
(
name
=
"gmock_link_test"
,
size
=
"small"
,
srcs
=
[
"gmock_link2_test.cc"
,
"gmock_link_test.cc"
,
"gmock_link_test.h"
,
],
deps
=
[
"//:gtest_main"
,
],
)
cc_binary
(
name
=
"gmock_output_test_"
,
srcs
=
[
"gmock_output_test_.cc"
],
deps
=
[
"//:gtest"
,
],
)
py_test
(
name
=
"gmock_output_test"
,
size
=
"medium"
,
srcs
=
[
"gmock_output_test.py"
],
data
=
[
":gmock_output_test_"
,
":gmock_output_test_golden.txt"
,
],
deps
=
[
":gmock_test_utils"
],
)
cc_test
(
name
=
"gmock_test"
,
size
=
"small"
,
srcs
=
[
"gmock_test.cc"
],
deps
=
[
"//:gtest_main"
,
],
)
googlemock/test/gmock-actions_test.cc
View file @
d4f77c1e
...
@@ -751,7 +751,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
...
@@ -751,7 +751,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
}
}
// Tests that DoDefault() returns the default value set by
// Tests that DoDefault() returns the default value set by
// DefaultValue<T>::Set() when it's not overriden by an ON_CALL().
// DefaultValue<T>::Set() when it's not overrid
d
en by an ON_CALL().
TEST
(
DoDefaultTest
,
ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne
)
{
TEST
(
DoDefaultTest
,
ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne
)
{
DefaultValue
<
int
>::
Set
(
1
);
DefaultValue
<
int
>::
Set
(
1
);
MockClass
mock
;
MockClass
mock
;
...
...
googlemock/test/gmock-matchers_test.cc
View file @
d4f77c1e
...
@@ -146,7 +146,6 @@ using testing::internal::ExplainMatchFailureTupleTo;
...
@@ -146,7 +146,6 @@ using testing::internal::ExplainMatchFailureTupleTo;
using
testing
::
internal
::
FloatingEqMatcher
;
using
testing
::
internal
::
FloatingEqMatcher
;
using
testing
::
internal
::
FormatMatcherDescription
;
using
testing
::
internal
::
FormatMatcherDescription
;
using
testing
::
internal
::
IsReadableTypeName
;
using
testing
::
internal
::
IsReadableTypeName
;
using
testing
::
internal
::
JoinAsTuple
;
using
testing
::
internal
::
linked_ptr
;
using
testing
::
internal
::
linked_ptr
;
using
testing
::
internal
::
MatchMatrix
;
using
testing
::
internal
::
MatchMatrix
;
using
testing
::
internal
::
RE
;
using
testing
::
internal
::
RE
;
...
@@ -872,9 +871,9 @@ class Unprintable {
...
@@ -872,9 +871,9 @@ class Unprintable {
char
c_
;
char
c_
;
};
};
inline
bool
operator
==
(
const
Unprintable
&
/* lhs */
,
inline
bool
operator
==
(
const
Unprintable
&
/* lhs */
,
const
Unprintable
&
/* rhs */
)
{
const
Unprintable
&
/* rhs */
)
{
return
true
;
return
true
;
}
}
TEST
(
EqTest
,
CanDescribeSelf
)
{
TEST
(
EqTest
,
CanDescribeSelf
)
{
...
@@ -915,7 +914,7 @@ TEST(TypedEqTest, CanDescribeSelf) {
...
@@ -915,7 +914,7 @@ TEST(TypedEqTest, CanDescribeSelf) {
// Type<T>::IsTypeOf(v) compiles iff the type of value v is T, where T
// Type<T>::IsTypeOf(v) compiles iff the type of value v is T, where T
// is a "bare" type (i.e. not in the form of const U or U&). If v's
// is a "bare" type (i.e. not in the form of const U or U&). If v's
// type is not T, the compiler will generate a message about
// type is not T, the compiler will generate a message about
// "undefined referece".
// "undefined refere
n
ce".
template
<
typename
T
>
template
<
typename
T
>
struct
Type
{
struct
Type
{
static
bool
IsTypeOf
(
const
T
&
/* v */
)
{
return
true
;
}
static
bool
IsTypeOf
(
const
T
&
/* v */
)
{
return
true
;
}
...
@@ -1424,7 +1423,7 @@ TEST(PairTest, MatchesCorrectly) {
...
@@ -1424,7 +1423,7 @@ TEST(PairTest, MatchesCorrectly) {
EXPECT_THAT
(
p
,
Pair
(
25
,
"foo"
));
EXPECT_THAT
(
p
,
Pair
(
25
,
"foo"
));
EXPECT_THAT
(
p
,
Pair
(
Ge
(
20
),
HasSubstr
(
"o"
)));
EXPECT_THAT
(
p
,
Pair
(
Ge
(
20
),
HasSubstr
(
"o"
)));
// 'first' does
nt'
match, but 'second' matches.
// 'first' does
not
match, but 'second' matches.
EXPECT_THAT
(
p
,
Not
(
Pair
(
42
,
"foo"
)));
EXPECT_THAT
(
p
,
Not
(
Pair
(
42
,
"foo"
)));
EXPECT_THAT
(
p
,
Not
(
Pair
(
Lt
(
25
),
"foo"
)));
EXPECT_THAT
(
p
,
Not
(
Pair
(
Lt
(
25
),
"foo"
)));
...
@@ -4263,7 +4262,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) {
...
@@ -4263,7 +4262,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) {
#endif // GTEST_HAS_TYPED_TEST
#endif // GTEST_HAS_TYPED_TEST
// Tests that mutliple missing values are reported.
// Tests that mutliple missing values are reported.
// Using just vector here, so order is predic
a
tble.
// Using just vector here, so order is predict
a
ble.
TEST
(
ContainerEqExtraTest
,
MultipleValuesMissing
)
{
TEST
(
ContainerEqExtraTest
,
MultipleValuesMissing
)
{
static
const
int
vals
[]
=
{
1
,
1
,
2
,
3
,
5
,
8
};
static
const
int
vals
[]
=
{
1
,
1
,
2
,
3
,
5
,
8
};
static
const
int
test_vals
[]
=
{
2
,
1
,
5
};
static
const
int
test_vals
[]
=
{
2
,
1
,
5
};
...
@@ -4276,7 +4275,7 @@ TEST(ContainerEqExtraTest, MultipleValuesMissing) {
...
@@ -4276,7 +4275,7 @@ TEST(ContainerEqExtraTest, MultipleValuesMissing) {
}
}
// Tests that added values are reported.
// Tests that added values are reported.
// Using just vector here, so order is predic
a
tble.
// Using just vector here, so order is predict
a
ble.
TEST
(
ContainerEqExtraTest
,
MultipleValuesAdded
)
{
TEST
(
ContainerEqExtraTest
,
MultipleValuesAdded
)
{
static
const
int
vals
[]
=
{
1
,
1
,
2
,
3
,
5
,
8
};
static
const
int
vals
[]
=
{
1
,
1
,
2
,
3
,
5
,
8
};
static
const
int
test_vals
[]
=
{
1
,
2
,
92
,
3
,
5
,
8
,
46
};
static
const
int
test_vals
[]
=
{
1
,
2
,
92
,
3
,
5
,
8
,
46
};
...
@@ -5268,28 +5267,6 @@ TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
...
@@ -5268,28 +5267,6 @@ TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
EXPECT_FALSE
(
IsReadableTypeName
(
"void (&)(int, bool, char, float)"
));
EXPECT_FALSE
(
IsReadableTypeName
(
"void (&)(int, bool, char, float)"
));
}
}
// Tests JoinAsTuple().
TEST
(
JoinAsTupleTest
,
JoinsEmptyTuple
)
{
EXPECT_EQ
(
""
,
JoinAsTuple
(
Strings
()));
}
TEST
(
JoinAsTupleTest
,
JoinsOneTuple
)
{
const
char
*
fields
[]
=
{
"1"
};
EXPECT_EQ
(
"1"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
1
)));
}
TEST
(
JoinAsTupleTest
,
JoinsTwoTuple
)
{
const
char
*
fields
[]
=
{
"1"
,
"a"
};
EXPECT_EQ
(
"(1, a)"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
2
)));
}
TEST
(
JoinAsTupleTest
,
JoinsTenTuple
)
{
const
char
*
fields
[]
=
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
};
EXPECT_EQ
(
"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)"
,
JoinAsTuple
(
Strings
(
fields
,
fields
+
10
)));
}
// Tests FormatMatcherDescription().
// Tests FormatMatcherDescription().
TEST
(
FormatMatcherDescriptionTest
,
WorksForEmptyDescription
)
{
TEST
(
FormatMatcherDescriptionTest
,
WorksForEmptyDescription
)
{
...
...
googlemock/test/gmock_output_test.py
View file @
d4f77c1e
...
@@ -31,11 +31,11 @@
...
@@ -31,11 +31,11 @@
"""Tests the text output of Google C++ Mocking Framework.
"""Tests the text output of Google C++ Mocking Framework.
SYNOPSIS
To update the golden file:
gmock_output_test.py --build_dir=BUILD/DIR --gengolden
gmock_output_test.py --build_dir=BUILD/DIR --gengolden
# where BUILD/DIR contains the built gmock_output_test_ file.
# where BUILD/DIR contains the built gmock_output_test_ file.
gmock_output_test.py --gengolden
gmock_output_test.py --gengolden
gmock_output_test.py
gmock_output_test.py
"""
"""
__author__
=
'wan@google.com (Zhanyong Wan)'
__author__
=
'wan@google.com (Zhanyong Wan)'
...
@@ -176,5 +176,8 @@ if __name__ == '__main__':
...
@@ -176,5 +176,8 @@ if __name__ == '__main__':
golden_file
=
open
(
GOLDEN_PATH
,
'wb'
)
golden_file
=
open
(
GOLDEN_PATH
,
'wb'
)
golden_file
.
write
(
output
)
golden_file
.
write
(
output
)
golden_file
.
close
()
golden_file
.
close
()
# Suppress the error "googletest was imported but a call to its main()
# was never detected."
os
.
_exit
(
0
)
else
:
else
:
gmock_test_utils
.
Main
()
gmock_test_utils
.
Main
()
googlemock/test/gmock_stress_test.cc
View file @
d4f77c1e
...
@@ -33,12 +33,13 @@
...
@@ -33,12 +33,13 @@
// threads concurrently.
// threads concurrently.
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
testing
{
namespace
testing
{
namespace
{
namespace
{
// From
<
gtest/internal/gtest-port.h
>
.
// From
"
gtest/internal/gtest-port.h
"
.
using
::
testing
::
internal
::
ThreadWithParam
;
using
::
testing
::
internal
::
ThreadWithParam
;
// The maximum number of test threads (not including helper threads)
// The maximum number of test threads (not including helper threads)
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment