summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorkosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386>2015-01-08 02:48:08 +0000
committerkosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386>2015-01-08 02:48:08 +0000
commit3e00742ca740d5a29d65a2d9bc4ec7fd9911c875 (patch)
tree1e4823d9b0396e2cc0c6240824e4e12f6a41a08c /scripts
parent419c7015c488d422ac35e3ea0fb066c2d99e37be (diff)
downloadgooglemock-3e00742ca740d5a29d65a2d9bc4ec7fd9911c875.tar.gz
Adding support to gmock_gen for nested templates.
git-svn-id: http://googlemock.googlecode.com/svn/trunk@503 8415998a-534a-0410-bf83-d39667b30386
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generator/cpp/ast.py7
-rwxr-xr-xscripts/generator/cpp/gmock_class_test.py36
-rwxr-xr-xscripts/generator/cpp/tokenize.py2
3 files changed, 41 insertions, 4 deletions
diff --git a/scripts/generator/cpp/ast.py b/scripts/generator/cpp/ast.py
index 201bf3a..11cbe91 100755
--- a/scripts/generator/cpp/ast.py
+++ b/scripts/generator/cpp/ast.py
@@ -496,9 +496,10 @@ class TypeConverter(object):
else:
names.append(t.name)
name = ''.join(names)
- result.append(Type(name_tokens[0].start, name_tokens[-1].end,
- name, templated_types, modifiers,
- reference, pointer, array))
+ if name_tokens:
+ result.append(Type(name_tokens[0].start, name_tokens[-1].end,
+ name, templated_types, modifiers,
+ reference, pointer, array))
del name_tokens[:]
i = 0
diff --git a/scripts/generator/cpp/gmock_class_test.py b/scripts/generator/cpp/gmock_class_test.py
index 27eb86c..018f90a 100755
--- a/scripts/generator/cpp/gmock_class_test.py
+++ b/scripts/generator/cpp/gmock_class_test.py
@@ -407,6 +407,42 @@ void());
self.assertEqualIgnoreLeadingWhitespace(
expected, self.GenerateMocks(source))
+ def testTemplateInATemplateTypedef(self):
+ source = """
+class Test {
+ public:
+ typedef std::vector<std::list<int>> FooType;
+ 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))
+
+ def testTemplateInATemplateTypedefWithComma(self):
+ source = """
+class Test {
+ public:
+ typedef std::function<void(
+ const vector<std::list<int>>&, int> FooType;
+ 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()
diff --git a/scripts/generator/cpp/tokenize.py b/scripts/generator/cpp/tokenize.py
index 28c3345..359d556 100755
--- a/scripts/generator/cpp/tokenize.py
+++ b/scripts/generator/cpp/tokenize.py
@@ -173,7 +173,7 @@ def GetTokens(source):
token_type = SYNTAX
i += 1
new_ch = source[i]
- if new_ch == c:
+ if new_ch == c and c != '>': # Treat ">>" as two tokens.
i += 1
elif c == '-' and new_ch == '>':
i += 1