mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Unit tests for variadic argument constructors
Explicit variadic constructors can be marked explicit as they can have one or more arguments
This commit is contained in:
parent
3591b2e540
commit
155994a4bd
|
@ -1338,6 +1338,47 @@ class CpplintTest(CpplintTestBase):
|
|||
Foo(std::initializer_list<T> &arg) {}
|
||||
};""",
|
||||
'')
|
||||
# Special case for variadic arguments
|
||||
error_collector = ErrorCollector(self.assert_)
|
||||
cpplint.ProcessFileData('foo.cc', 'cc',
|
||||
['class Foo {',
|
||||
' template<typename... Args>',
|
||||
' explicit Foo(const int arg, Args&&... args) {}',
|
||||
'};'],
|
||||
error_collector)
|
||||
self.assertEquals(0, error_collector.ResultList().count(
|
||||
'Constructors that require multiple arguments should not be marked '
|
||||
'explicit. [runtime/explicit] [0]'))
|
||||
error_collector = ErrorCollector(self.assert_)
|
||||
cpplint.ProcessFileData('foo.cc', 'cc',
|
||||
['class Foo {',
|
||||
' template<typename... Args>',
|
||||
' explicit Foo(Args&&... args) {}',
|
||||
'};'],
|
||||
error_collector)
|
||||
self.assertEquals(0, error_collector.ResultList().count(
|
||||
'Constructors that require multiple arguments should not be marked '
|
||||
'explicit. [runtime/explicit] [0]'))
|
||||
error_collector = ErrorCollector(self.assert_)
|
||||
cpplint.ProcessFileData('foo.cc', 'cc',
|
||||
['class Foo {',
|
||||
' template<typename... Args>',
|
||||
' Foo(const int arg, Args&&... args) {}',
|
||||
'};'],
|
||||
error_collector)
|
||||
self.assertEquals(1, error_collector.ResultList().count(
|
||||
'Constructors callable with one argument should be marked explicit.'
|
||||
' [runtime/explicit] [5]'))
|
||||
error_collector = ErrorCollector(self.assert_)
|
||||
cpplint.ProcessFileData('foo.cc', 'cc',
|
||||
['class Foo {',
|
||||
' template<typename... Args>',
|
||||
' Foo(Args&&... args) {}',
|
||||
'};'],
|
||||
error_collector)
|
||||
self.assertEquals(1, error_collector.ResultList().count(
|
||||
'Constructors callable with one argument should be marked explicit.'
|
||||
' [runtime/explicit] [5]'))
|
||||
# Anything goes inside an assembly block
|
||||
error_collector = ErrorCollector(self.assert_)
|
||||
cpplint.ProcessFileData('foo.cc', 'cc',
|
||||
|
|
Loading…
Reference in New Issue
Block a user