Add cpplint unit tests for short lambdas

This commit is contained in:
Matt Clarkson 2015-10-01 13:51:08 +01:00
parent 3591b2e540
commit 355baf6964

View File

@ -3182,6 +3182,54 @@ class CpplintTest(CpplintTestBase):
error_collector) error_collector)
cpplint._cpplint_state.verbose_level = old_verbose_level cpplint._cpplint_state.verbose_level = old_verbose_level
def testLambdasOnSameLine(self):
error_collector = ErrorCollector(self.assert_)
old_verbose_level = cpplint._cpplint_state.verbose_level
cpplint._cpplint_state.verbose_level = 0
cpplint.ProcessFileData('foo.cc', 'cc',
['const auto lambda = '
'[](const int i) { return i; };'],
error_collector)
cpplint._cpplint_state.verbose_level = old_verbose_level
self.assertEquals(0, error_collector.Results().count(
'More than one command on the same line [whitespace/newline] [0]'))
error_collector = ErrorCollector(self.assert_)
old_verbose_level = cpplint._cpplint_state.verbose_level
cpplint._cpplint_state.verbose_level = 0
cpplint.ProcessFileData('foo.cc', 'cc',
['const auto result = std::any_of(vector.begin(), '
'vector.end(), '
'[](const int i) { return i > 0; });'],
error_collector)
cpplint._cpplint_state.verbose_level = old_verbose_level
self.assertEquals(0, error_collector.Results().count(
'More than one command on the same line [whitespace/newline] [0]'))
error_collector = ErrorCollector(self.assert_)
old_verbose_level = cpplint._cpplint_state.verbose_level
cpplint._cpplint_state.verbose_level = 0
cpplint.ProcessFileData('foo.cc', 'cc',
['return mutex::Lock<void>([this]() { '
'this->ReadLock(); }, [this]() { '
'this->ReadUnlock(); });'],
error_collector)
cpplint._cpplint_state.verbose_level = old_verbose_level
self.assertEquals(0, error_collector.Results().count(
'More than one command on the same line [whitespace/newline] [0]'))
error_collector = ErrorCollector(self.assert_)
old_verbose_level = cpplint._cpplint_state.verbose_level
cpplint._cpplint_state.verbose_level = 0
cpplint.ProcessFileData('foo.cc', 'cc',
['return mutex::Lock<void>([this]() { '
'this->ReadLock(); }, [this]() { '
'this->ReadUnlock(); }, object);'],
error_collector)
cpplint._cpplint_state.verbose_level = old_verbose_level
self.assertEquals(0, error_collector.Results().count(
'More than one command on the same line [whitespace/newline] [0]'))
def testEndOfNamespaceComments(self): def testEndOfNamespaceComments(self):
error_collector = ErrorCollector(self.assert_) error_collector = ErrorCollector(self.assert_)
cpplint.ProcessFileData('foo.cc', 'cc', cpplint.ProcessFileData('foo.cc', 'cc',