Skip to content

Commit

Permalink
Add unit tests for constexpr constructors
Browse files Browse the repository at this point in the history
This also adds unit tests for inline+explicit constructors being okay,
with and without constexpr.
  • Loading branch information
danakj committed Mar 2, 2017
1 parent cf4071c commit 2db65fe
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions cpplint/cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,80 @@ class Foo {
};""",
'Single-parameter constructors should be marked explicit.'
' [runtime/explicit] [5]')
# missing explicit for constexpr constructors is bad as well
self.TestMultiLineLint(
"""
class Foo {
constexpr Foo(int f);
};""",
'Single-parameter constructors should be marked explicit.'
' [runtime/explicit] [5]')
# missing explicit for constexpr+inline constructors is bad as well
self.TestMultiLineLint(
"""
class Foo {
constexpr inline Foo(int f);
};""",
'Single-parameter constructors should be marked explicit.'
' [runtime/explicit] [5]')
self.TestMultiLineLint(
"""
class Foo {
inline constexpr Foo(int f);
};""",
'Single-parameter constructors should be marked explicit.'
' [runtime/explicit] [5]')
# explicit with inline is accepted
self.TestMultiLineLint(
"""
class Foo {
inline explicit Foo(int f);
};""",
'')
self.TestMultiLineLint(
"""
class Foo {
explicit inline Foo(int f);
};""",
'')
# explicit with constexpr is accepted
self.TestMultiLineLint(
"""
class Foo {
constexpr explicit Foo(int f);
};""",
'')
self.TestMultiLineLint(
"""
class Foo {
explicit constexpr Foo(int f);
};""",
'')
# explicit with constexpr+inline is accepted
self.TestMultiLineLint(
"""
class Foo {
inline constexpr explicit Foo(int f);
};""",
'')
self.TestMultiLineLint(
"""
class Foo {
explicit inline constexpr Foo(int f);
};""",
'')
self.TestMultiLineLint(
"""
class Foo {
constexpr inline explicit Foo(int f);
};""",
'')
self.TestMultiLineLint(
"""
class Foo {
explicit constexpr inline Foo(int f);
};""",
'')
# structs are caught as well.
self.TestMultiLineLint(
"""
Expand Down

0 comments on commit 2db65fe

Please sign in to comment.