Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f58b49a2
Commit
f58b49a2
authored
Nov 17, 2014
by
kosak
Browse files
Handle parameters without variable names when the type includes *, & or [].
parent
6e87b780
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
scripts/generator/cpp/ast.py
scripts/generator/cpp/ast.py
+3
-4
scripts/generator/cpp/gmock_class_test.py
scripts/generator/cpp/gmock_class_test.py
+30
-0
No files found.
scripts/generator/cpp/ast.py
View file @
f58b49a2
...
@@ -598,10 +598,9 @@ class TypeConverter(object):
...
@@ -598,10 +598,9 @@ class TypeConverter(object):
first_token
=
None
first_token
=
None
default
=
[]
default
=
[]
def
AddParameter
():
def
AddParameter
(
end
):
if
default
:
if
default
:
del
default
[
0
]
# Remove flag.
del
default
[
0
]
# Remove flag.
end
=
type_modifiers
[
-
1
].
end
parts
=
self
.
DeclarationToParts
(
type_modifiers
,
True
)
parts
=
self
.
DeclarationToParts
(
type_modifiers
,
True
)
(
name
,
type_name
,
templated_types
,
modifiers
,
(
name
,
type_name
,
templated_types
,
modifiers
,
unused_default
,
unused_other_tokens
)
=
parts
unused_default
,
unused_other_tokens
)
=
parts
...
@@ -625,7 +624,7 @@ class TypeConverter(object):
...
@@ -625,7 +624,7 @@ class TypeConverter(object):
continue
continue
if
s
.
name
==
','
:
if
s
.
name
==
','
:
AddParameter
()
AddParameter
(
s
.
start
)
name
=
type_name
=
''
name
=
type_name
=
''
type_modifiers
=
[]
type_modifiers
=
[]
pointer
=
reference
=
array
=
False
pointer
=
reference
=
array
=
False
...
@@ -646,7 +645,7 @@ class TypeConverter(object):
...
@@ -646,7 +645,7 @@ class TypeConverter(object):
default
.
append
(
s
)
default
.
append
(
s
)
else
:
else
:
type_modifiers
.
append
(
s
)
type_modifiers
.
append
(
s
)
AddParameter
()
AddParameter
(
tokens
[
-
1
].
end
)
return
result
return
result
def
CreateReturnType
(
self
,
return_type_seq
):
def
CreateReturnType
(
self
,
return_type_seq
):
...
...
scripts/generator/cpp/gmock_class_test.py
View file @
f58b49a2
...
@@ -219,6 +219,36 @@ class Foo {
...
@@ -219,6 +219,36 @@ class Foo {
'MOCK_METHOD0_T(Bar,
\n
int());'
,
'MOCK_METHOD0_T(Bar,
\n
int());'
,
self
.
GenerateMethodSource
(
source
))
self
.
GenerateMethodSource
(
source
))
def
testPointerArgWithoutNames
(
self
):
source
=
"""
class Foo {
virtual int Bar(C*);
};
"""
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD1(Bar,
\n
int(C*));'
,
self
.
GenerateMethodSource
(
source
))
def
testReferenceArgWithoutNames
(
self
):
source
=
"""
class Foo {
virtual int Bar(C&);
};
"""
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD1(Bar,
\n
int(C&));'
,
self
.
GenerateMethodSource
(
source
))
def
testArrayArgWithoutNames
(
self
):
source
=
"""
class Foo {
virtual int Bar(C[]);
};
"""
self
.
assertEqualIgnoreLeadingWhitespace
(
'MOCK_METHOD1(Bar,
\n
int(C[]));'
,
self
.
GenerateMethodSource
(
source
))
class
GenerateMocksTest
(
TestCase
):
class
GenerateMocksTest
(
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment