diff --git a/cpplint/cpplint_unittest.py b/cpplint/cpplint_unittest.py index aaa3b24..42a7cb6 100755 --- a/cpplint/cpplint_unittest.py +++ b/cpplint/cpplint_unittest.py @@ -1338,6 +1338,47 @@ class CpplintTest(CpplintTestBase): Foo(std::initializer_list &arg) {} };""", '') + # Special case for variadic arguments + error_collector = ErrorCollector(self.assert_) + cpplint.ProcessFileData('foo.cc', 'cc', + ['class Foo {', + ' template', + ' 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', + ' 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', + ' 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', + ' 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',