diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-08-21 14:32:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 14:32:21 (GMT) |
commit | b88511ef640c046ec9c7553b383a2aba64c80967 (patch) | |
tree | da0d99ab08f13a66da37b66c5f07bbd603ad72bc | |
parent | 735bd75f69f8a1c6240c95915edfa091bfa976ac (diff) | |
parent | a6e7ba27c73726169811f3ae157951d946179499 (diff) | |
download | googletest-b88511ef640c046ec9c7553b383a2aba64c80967.zip googletest-b88511ef640c046ec9c7553b383a2aba64c80967.tar.gz googletest-b88511ef640c046ec9c7553b383a2aba64c80967.tar.bz2 |
Merge pull request #1194 from joshbodily/josh/fix_scoped_class2
Fix scoped enum not working in gmock-gen.py
-rwxr-xr-x | googlemock/scripts/generator/cpp/ast.py | 3 | ||||
-rwxr-xr-x | googlemock/scripts/generator/cpp/gmock_class_test.py | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/googlemock/scripts/generator/cpp/ast.py b/googlemock/scripts/generator/cpp/ast.py index cce3272..f14728b 100755 --- a/googlemock/scripts/generator/cpp/ast.py +++ b/googlemock/scripts/generator/cpp/ast.py @@ -1264,6 +1264,9 @@ class AstBuilder(object): return self._GetNestedType(Union) def handle_enum(self): + token = self._GetNextToken() + if not (token.token_type == tokenize.NAME and token.name == 'class'): + self._AddBackToken(token) return self._GetNestedType(Enum) def handle_auto(self): diff --git a/googlemock/scripts/generator/cpp/gmock_class_test.py b/googlemock/scripts/generator/cpp/gmock_class_test.py index 018f90a..c53e600 100755 --- a/googlemock/scripts/generator/cpp/gmock_class_test.py +++ b/googlemock/scripts/generator/cpp/gmock_class_test.py @@ -444,5 +444,23 @@ void(const FooType& test_arg)); self.assertEqualIgnoreLeadingWhitespace( expected, self.GenerateMocks(source)) + def testEnumClass(self): + source = """ +class Test { + public: + enum class Baz { BAZINGA }; + virtual void Bar(const FooType& test_arg); +}; +""" + expected = """\ +class MockTest : public Test { +public: +MOCK_METHOD1(Bar, +void(const FooType& test_arg)); +}; +""" + self.assertEqualIgnoreLeadingWhitespace( + expected, self.GenerateMocks(source)) + if __name__ == '__main__': unittest.main() |