Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
387bdd55
Commit
387bdd55
authored
Jul 20, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Makes ByRef(x) printable as a reference to x.
parent
b5937dab
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
1 deletion
+32
-1
gmock-generated-actions.h
include/gmock/gmock-generated-actions.h
+11
-0
gmock-generated-actions.h.pump
include/gmock/gmock-generated-actions.h.pump
+11
-0
gmock_doctor.py
scripts/gmock_doctor.py
+0
-1
gmock-generated-actions_test.cc
test/gmock-generated-actions_test.cc
+10
-0
No files found.
include/gmock/gmock-generated-actions.h
View file @
387bdd55
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#include <gmock/gmock-actions.h>
#include <gmock/gmock-actions.h>
#include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-port.h>
#include <gmock/internal/gmock-port.h>
namespace
testing
{
namespace
testing
{
...
@@ -321,6 +322,9 @@ class InvokeMethodAction {
...
@@ -321,6 +322,9 @@ class InvokeMethodAction {
const
MethodPtr
method_ptr_
;
const
MethodPtr
method_ptr_
;
};
};
// TODO(wan@google.com): ReferenceWrapper and ByRef() are neither
// action-specific nor variadic. Move them to a better place.
// A ReferenceWrapper<T> object represents a reference to type T,
// A ReferenceWrapper<T> object represents a reference to type T,
// which can be either const or not. It can be explicitly converted
// which can be either const or not. It can be explicitly converted
// from, and implicitly converted to, a T&. Unlike a reference,
// from, and implicitly converted to, a T&. Unlike a reference,
...
@@ -341,6 +345,13 @@ class ReferenceWrapper {
...
@@ -341,6 +345,13 @@ class ReferenceWrapper {
T
*
pointer_
;
T
*
pointer_
;
};
};
// Allows the expression ByRef(x) to be printed as a reference to x.
template
<
typename
T
>
void
PrintTo
(
const
ReferenceWrapper
<
T
>&
ref
,
::
std
::
ostream
*
os
)
{
T
&
value
=
ref
;
UniversalPrinter
<
T
&>::
Print
(
value
,
os
);
}
// CallableHelper has static methods for invoking "callables",
// CallableHelper has static methods for invoking "callables",
// i.e. function pointers and functors. It uses overloading to
// i.e. function pointers and functors. It uses overloading to
// provide a uniform interface for invoking different kinds of
// provide a uniform interface for invoking different kinds of
...
...
include/gmock/gmock-generated-actions.h.pump
View file @
387bdd55
...
@@ -43,6 +43,7 @@ $$}} This meta comment fixes auto-indentation in editors.
...
@@ -43,6 +43,7 @@ $$}} This meta comment fixes auto-indentation in editors.
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#include <gmock/gmock-actions.h>
#include <gmock/gmock-actions.h>
#include <gmock/gmock-printers.h>
#include <gmock/internal/gmock-port.h>
#include <gmock/internal/gmock-port.h>
namespace
testing
{
namespace
testing
{
...
@@ -123,6 +124,9 @@ class InvokeMethodAction {
...
@@ -123,6 +124,9 @@ class InvokeMethodAction {
const
MethodPtr
method_ptr_
;
const
MethodPtr
method_ptr_
;
};
};
// TODO(wan@google.com): ReferenceWrapper and ByRef() are neither
// action-specific nor variadic. Move them to a better place.
// A ReferenceWrapper<T> object represents a reference to type T,
// A ReferenceWrapper<T> object represents a reference to type T,
// which can be either const or not. It can be explicitly converted
// which can be either const or not. It can be explicitly converted
// from, and implicitly converted to, a T&. Unlike a reference,
// from, and implicitly converted to, a T&. Unlike a reference,
...
@@ -143,6 +147,13 @@ class ReferenceWrapper {
...
@@ -143,6 +147,13 @@ class ReferenceWrapper {
T
*
pointer_
;
T
*
pointer_
;
};
};
// Allows the expression ByRef(x) to be printed as a reference to x.
template
<
typename
T
>
void
PrintTo
(
const
ReferenceWrapper
<
T
>&
ref
,
::
std
::
ostream
*
os
)
{
T
&
value
=
ref
;
UniversalPrinter
<
T
&>::
Print
(
value
,
os
);
}
// CallableHelper has static methods for invoking "callables",
// CallableHelper has static methods for invoking "callables",
// i.e. function pointers and functors. It uses overloading to
// i.e. function pointers and functors. It uses overloading to
// provide a uniform interface for invoking different kinds of
// provide a uniform interface for invoking different kinds of
...
...
scripts/gmock_doctor.py
View file @
387bdd55
...
@@ -71,7 +71,6 @@ _COMMON_GMOCK_SYMBOLS = [
...
@@ -71,7 +71,6 @@ _COMMON_GMOCK_SYMBOLS = [
'Not'
,
'Not'
,
'NotNull'
,
'NotNull'
,
'Pointee'
,
'Pointee'
,
'PointeeIsInitializedProto'
,
'Property'
,
'Property'
,
'Ref'
,
'Ref'
,
'ResultOf'
,
'ResultOf'
,
...
...
test/gmock-generated-actions_test.cc
View file @
387bdd55
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <gmock/gmock-generated-actions.h>
#include <gmock/gmock-generated-actions.h>
#include <functional>
#include <functional>
#include <sstream>
#include <string>
#include <string>
#include <gmock/gmock.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
...
@@ -546,6 +547,15 @@ TEST(ByRefTest, ExplicitType) {
...
@@ -546,6 +547,15 @@ TEST(ByRefTest, ExplicitType) {
// ByRef<Derived>(b);
// ByRef<Derived>(b);
}
}
// Tests that Google Mock prints expression ByRef(x) as a reference to x.
TEST
(
ByRefTest
,
PrintsCorrectly
)
{
int
n
=
42
;
::
std
::
stringstream
expected
,
actual
;
testing
::
internal
::
UniversalPrinter
<
const
int
&>::
Print
(
n
,
&
expected
);
testing
::
internal
::
UniversalPrint
(
ByRef
(
n
),
&
actual
);
EXPECT_EQ
(
expected
.
str
(),
actual
.
str
());
}
// Tests InvokeArgument<N>(...).
// Tests InvokeArgument<N>(...).
// Tests using InvokeArgument with a nullary function.
// Tests using InvokeArgument with a nullary function.
...
...
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