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
61adbcc5
Commit
61adbcc5
authored
Nov 17, 2014
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for C++11 explicitly defaulted and deleted special member functions…
Add support for C++11 explicitly defaulted and deleted special member functions in the gmock generator.
parent
055b6b17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
ast.py
scripts/generator/cpp/ast.py
+11
-4
gmock_class_test.py
scripts/generator/cpp/gmock_class_test.py
+62
-0
No files found.
scripts/generator/cpp/ast.py
View file @
61adbcc5
...
...
@@ -1081,10 +1081,17 @@ class AstBuilder(object):
body
=
None
if
token
.
name
==
'='
:
token
=
self
.
_GetNextToken
()
assert
token
.
token_type
==
tokenize
.
CONSTANT
,
token
assert
token
.
name
==
'0'
,
token
modifiers
|=
FUNCTION_PURE_VIRTUAL
token
=
self
.
_GetNextToken
()
if
token
.
name
==
'default'
or
token
.
name
==
'delete'
:
# Ignore explicitly defaulted and deleted special members
# in C++11.
token
=
self
.
_GetNextToken
()
else
:
# Handle pure-virtual declarations.
assert
token
.
token_type
==
tokenize
.
CONSTANT
,
token
assert
token
.
name
==
'0'
,
token
modifiers
|=
FUNCTION_PURE_VIRTUAL
token
=
self
.
_GetNextToken
()
if
token
.
name
==
'['
:
# TODO(nnorwitz): store tokens and improve parsing.
...
...
scripts/generator/cpp/gmock_class_test.py
View file @
61adbcc5
...
...
@@ -65,6 +65,68 @@ class Foo {
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testSimpleConstructorsAndDestructor
(
self
):
source
=
"""
class Foo {
public:
Foo();
Foo(int x);
Foo(const Foo& f);
Foo(Foo&& f);
~Foo();
virtual int Bar() = 0;
};
"""
# The constructors and destructor should be ignored.
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testVirtualDestructor
(
self
):
source
=
"""
class Foo {
public:
virtual ~Foo();
virtual int Bar() = 0;
};
"""
# The destructor should be ignored.
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testExplicitlyDefaultedConstructorsAndDestructor
(
self
):
source
=
"""
class Foo {
public:
Foo() = default;
Foo(const Foo& f) = default;
Foo(Foo&& f) = default;
~Foo() = default;
virtual int Bar() = 0;
};
"""
# The constructors and destructor should be ignored.
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testExplicitlyDeletedConstructorsAndDestructor
(
self
):
source
=
"""
class Foo {
public:
Foo() = delete;
Foo(const Foo& f) = delete;
Foo(Foo&& f) = delete;
~Foo() = delete;
virtual int Bar() = 0;
};
"""
# The constructors and destructor should be ignored.
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD0(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
def
testSimpleOverrideMethod
(
self
):
source
=
"""
class Foo {
...
...
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