From 45fef502fac471efa4bf25b3d4104943463912eb Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Fri, 6 Sep 2013 22:52:14 +0000 Subject: makes googlemock generator handle some class templates; pulls in gtest r662 --- scripts/generator/cpp/gmock_class_test.py | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'scripts/generator/cpp/gmock_class_test.py') diff --git a/scripts/generator/cpp/gmock_class_test.py b/scripts/generator/cpp/gmock_class_test.py index 7aa70276..07d59571 100755 --- a/scripts/generator/cpp/gmock_class_test.py +++ b/scripts/generator/cpp/gmock_class_test.py @@ -196,6 +196,18 @@ class Foo { 'MOCK_METHOD0(Bar,\nmap());', self.GenerateMethodSource(source)) + def testSimpleMethodInTemplatedClass(self): + source = """ +template +class Foo { + public: + virtual int Bar(); +}; +""" + self.assertEqualIgnoreLeadingWhitespace( + 'MOCK_METHOD0_T(Bar,\nint());', + self.GenerateMethodSource(source)) + class GenerateMocksTest(TestCase): @@ -255,5 +267,43 @@ void()); self.assertEqualIgnoreLeadingWhitespace( expected, self.GenerateMocks(source)) + def testTemplatedForwardDeclaration(self): + source = """ +template class Forward; // Forward declaration should be ignored. +class Test { + public: + virtual void Foo(); +}; +""" + expected = """\ +class MockTest : public Test { +public: +MOCK_METHOD0(Foo, +void()); +}; +""" + self.assertEqualIgnoreLeadingWhitespace( + expected, self.GenerateMocks(source)) + + def testTemplatedClass(self): + source = """ +template +class Test { + public: + virtual void Foo(); +}; +""" + expected = """\ +template +class MockTest : public Test { +public: +MOCK_METHOD0_T(Foo, +void()); +}; +""" + self.assertEqualIgnoreLeadingWhitespace( + expected, self.GenerateMocks(source)) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3