Add support for C++11 explicitly defaulted and deleted special member functions in the gmock generator.
This commit is contained in:
parent
055b6b17d2
commit
61adbcc5c6
|
@ -1081,10 +1081,17 @@ class AstBuilder(object):
|
||||||
body = None
|
body = None
|
||||||
if token.name == '=':
|
if token.name == '=':
|
||||||
token = self._GetNextToken()
|
token = self._GetNextToken()
|
||||||
assert token.token_type == tokenize.CONSTANT, token
|
|
||||||
assert token.name == '0', token
|
if token.name == 'default' or token.name == 'delete':
|
||||||
modifiers |= FUNCTION_PURE_VIRTUAL
|
# Ignore explicitly defaulted and deleted special members
|
||||||
token = self._GetNextToken()
|
# 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 == '[':
|
if token.name == '[':
|
||||||
# TODO(nnorwitz): store tokens and improve parsing.
|
# TODO(nnorwitz): store tokens and improve parsing.
|
||||||
|
|
|
@ -65,6 +65,68 @@ class Foo {
|
||||||
'MOCK_METHOD0(Bar,\nint());',
|
'MOCK_METHOD0(Bar,\nint());',
|
||||||
self.GenerateMethodSource(source))
|
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,\nint());',
|
||||||
|
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,\nint());',
|
||||||
|
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,\nint());',
|
||||||
|
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,\nint());',
|
||||||
|
self.GenerateMethodSource(source))
|
||||||
|
|
||||||
def testSimpleOverrideMethod(self):
|
def testSimpleOverrideMethod(self):
|
||||||
source = """
|
source = """
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user