From 05c4a036bbed85ece96476e7cfc3ba2507567dd6 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 24 Jun 2020 23:00:53 -0400 Subject: [PATCH] Googletest export Update auto_mock to support C++17 nested namespaces PiperOrigin-RevId: 318192214 --- googlemock/scripts/generator/cpp/ast.py | 7 +++---- googlemock/scripts/generator/cpp/gmock_class_test.py | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/googlemock/scripts/generator/cpp/ast.py b/googlemock/scripts/generator/cpp/ast.py index b4890a54..cc9f89aa 100755 --- a/googlemock/scripts/generator/cpp/ast.py +++ b/googlemock/scripts/generator/cpp/ast.py @@ -1599,12 +1599,11 @@ class AstBuilder(object): bases, templated_types, body, self.namespace_stack) def handle_namespace(self): - token = self._GetNextToken() # Support anonymous namespaces. name = None - if token.token_type == tokenize.NAME: - name = token.name - token = self._GetNextToken() + name_tokens, token = self.GetName() + if name_tokens: + name = ''.join([t.name for t in name_tokens]) self.namespace_stack.append(name) assert token.token_type == tokenize.SYNTAX, token # Create an internal token that denotes when the namespace is complete. diff --git a/googlemock/scripts/generator/cpp/gmock_class_test.py b/googlemock/scripts/generator/cpp/gmock_class_test.py index 74655692..527182cc 100755 --- a/googlemock/scripts/generator/cpp/gmock_class_test.py +++ b/googlemock/scripts/generator/cpp/gmock_class_test.py @@ -361,26 +361,26 @@ class GenerateMocksTest(TestCase): source = """ namespace Foo { namespace Bar { class Forward; } -namespace Baz { +namespace Baz::Qux { class Test { public: virtual void Foo(); }; -} // namespace Baz +} // namespace Baz::Qux } // namespace Foo """ expected = """\ namespace Foo { -namespace Baz { +namespace Baz::Qux { class MockTest : public Test { public: MOCK_METHOD(void, Foo, (), (override)); }; -} // namespace Baz +} // namespace Baz::Qux } // namespace Foo """ self.assertEqualIgnoreLeadingWhitespace(expected,