Lines Matching refs:TestLint
217 def TestLint(self, code, expected_message): member in CpplintTestBase
363 self.TestLint(
370 self.TestLint(
373 self.TestLint(
377 self.TestLint(
381 self.TestLint(
384 self.TestLint(
387 self.TestLint(
391 self.TestLint(
394 self.TestLint(
397 self.TestLint(
401 self.TestLint(
404 self.TestLint(
407 self.TestLint(
431 self.TestLint(
439 self.TestLint(
444 self.TestLint('long a = (int64) 65; // NOLINT', '')
445 self.TestLint('long a = (int64) 65; // NOLINT(*)', '')
447 self.TestLint(
454 self.TestLint(
543 self.TestLint(
547 self.TestLint(
550 self.TestLint(
557 self.TestLint(
561 self.TestLint(
565 self.TestLint(
570 self.TestLint(
574 self.TestLint(
578 self.TestLint(
584 self.TestLint('u a = (u)NULL;', '')
585 self.TestLint('uint a = (uint)NULL;', '')
586 self.TestLint('typedef MockCallback<int(int)> CallbackType;', '')
587 self.TestLint('scoped_ptr< MockCallback<int(int)> > callback_value;', '')
588 self.TestLint('std::function<int(bool)>', '')
589 self.TestLint('x = sizeof(int)', '')
590 self.TestLint('x = alignof(int)', '')
591 self.TestLint('alignas(int) char x[42]', '')
592 self.TestLint('alignas(alignof(x)) char y[42]', '')
593 self.TestLint('void F(int (func)(int));', '')
594 self.TestLint('void F(int (func)(int*));', '')
595 self.TestLint('void F(int (Class::member)(int));', '')
596 self.TestLint('void F(int (Class::member)(int*));', '')
597 self.TestLint('void F(int (Class::member)(int), int param);', '')
598 self.TestLint('void F(int (Class::member)(int*), int param);', '')
601 self.TestLint('[](int/*unused*/) -> bool {', '')
602 self.TestLint('[](int /*unused*/) -> bool {', '')
603 self.TestLint('auto f = [](MyStruct* /*unused*/)->int {', '')
604 self.TestLint('[](int) -> bool {', '')
605 self.TestLint('auto f = [](MyStruct*)->int {', '')
608 self.TestLint('int64_t{4096} * 1000 * 1000', '')
609 self.TestLint('size_t{4096} * 1000 * 1000', '')
610 self.TestLint('uint_fast16_t{4096} * 1000 * 1000', '')
660 self.TestLint('int* x = &static_cast<int*>(foo);', error_msg)
661 self.TestLint('int* x = &reinterpret_cast<int *>(foo);', error_msg)
662 self.TestLint('int* x = &(int*)foo;',
666 self.TestLint('BudgetBuckets&(BudgetWinHistory::*BucketFn)(void) const;',
668 self.TestLint('&(*func_ptr)(arg)', '')
669 self.TestLint('Compute(arg, &(*func_ptr)(i, j));', '')
676 self.TestLint('int* x = &down_cast<Obj*>(obj)->member_;', alt_error_msg)
677 self.TestLint('int* x = &down_cast<Obj*>(obj)[index];', alt_error_msg)
678 self.TestLint('int* x = &(down_cast<Obj*>(obj)->member_);', '')
679 self.TestLint('int* x = &(down_cast<Obj*>(obj)[index]);', '')
680 self.TestLint('int* x = &down_cast<Obj*>(obj)\n->member_;', alt_error_msg)
681 self.TestLint('int* x = &(down_cast<Obj*>(obj)\n->member_);', '')
684 self.TestLint('int* x = reinterpret_cast<int *>(&foo);', '')
688 self.TestLint('auto x = implicit_cast<string &(*)(int)>(&foo);', '')
691 self.TestLint(
695 self.TestLint(
699 self.TestLint(
702 self.TestLint(
708 self.TestLint('virtual void Func(int*) const;', '')
709 self.TestLint('virtual void Func(int*);', '')
710 self.TestLint('void Method(char*) {', '')
711 self.TestLint('void Method(char*);', '')
712 self.TestLint('static void operator delete[](void*) throw();', '')
713 self.TestLint('int Method(int);', '')
715 self.TestLint('virtual void Func(int* p);', '')
716 self.TestLint('void operator delete(void* x) throw();', '')
717 self.TestLint('void Method(char* x) {', '')
718 self.TestLint('void Method(char* /*x*/) {', '')
719 self.TestLint('void Method(char* x);', '')
720 self.TestLint('typedef void (*Method)(int32 x);', '')
721 self.TestLint('static void operator delete[](void* x) throw();', '')
722 self.TestLint('static void operator delete[](void* /*x*/) throw();', '')
724 self.TestLint('X operator++(int);', '')
725 self.TestLint('X operator++(int) {', '')
726 self.TestLint('X operator--(int);', '')
727 self.TestLint('X operator--(int /*unused*/) {', '')
728 self.TestLint('MACRO(int);', '')
729 self.TestLint('MACRO(func(int));', '')
730 self.TestLint('MACRO(arg, func(int));', '')
732 self.TestLint('void (*func)(void*);', '')
733 self.TestLint('void Func((*func)(void*)) {}', '')
734 self.TestLint('template <void Func(void*)> void func();', '')
735 self.TestLint('virtual void f(int /*unused*/) {', '')
736 self.TestLint('void f(int /*unused*/) override {', '')
737 self.TestLint('void f(int /*unused*/) final {', '')
741 self.TestLint(
747 self.TestLint(
753 self.TestLint(
760 self.TestLint('int a = int();', '') # constructor
761 self.TestLint('X::X() : a(int()) {}', '') # default constructor
762 self.TestLint('operator bool();', '') # Conversion operator
763 self.TestLint('new int64(123);', '') # "new" operator on basic type
764 self.TestLint('new int64(123);', '') # "new" operator on basic type
765 self.TestLint('new const int(42);', '') # "new" on const-qualified type
766 self.TestLint('using a = bool(int arg);', '') # C++11 alias-declaration
767 self.TestLint('x = bit_cast<double(*)[3]>(y);', '') # array of array
768 self.TestLint('void F(const char(&src)[N]);', '') # array of references
771 self.TestLint(
776 self.TestLint('std::function<int(bool)>', '')
777 self.TestLint('std::function<const int(bool)>', '')
778 self.TestLint('std::function< int(bool) >', '')
779 self.TestLint('mfunction<int(bool)>', '')
792 self.TestLint('typedef bool(FunctionPointer)();', '')
793 self.TestLint('typedef bool(FunctionPointer)(int param);', '')
794 self.TestLint('typedef bool(MyClass::*MemberFunctionPointer)();', '')
795 self.TestLint('typedef bool(MyClass::* MemberFunctionPointer)();', '')
796 self.TestLint('typedef bool(MyClass::*MemberFunctionPointer)() const;', '')
797 self.TestLint('void Function(bool(FunctionPointerArg)());', '')
798 self.TestLint('void Function(bool(FunctionPointerArg)()) {}', '')
799 self.TestLint('typedef set<int64, bool(*)(int64, int64)> SortedIdSet', '')
800 self.TestLint(
807 self.TestLint(
810 self.TestLint(
813 self.TestLint(
816 self.TestLint(
849 self.TestLint(
852 self.TestLint(
858 self.TestLint(
861 self.TestLint(
869 self.TestLint(
872 self.TestLint(
875 self.TestLint(
878 self.TestLint(
1650 self.TestLint(
1653 self.TestLint(
1662 self.TestLint(
1667 self.TestLint(
1671 self.TestLint(
1678 self.TestLint(
1681 self.TestLint(
1684 self.TestLint(
1687 self.TestLint(
1690 self.TestLint(
1695 self.TestLint('virtual void F()', '')
1696 self.TestLint('virtual void F();', '')
1697 self.TestLint('virtual void F() {}', '')
1703 self.TestLint('virtual int F() %s' % virt_specifier, error_message)
1704 self.TestLint('virtual int F() %s;' % virt_specifier, error_message)
1705 self.TestLint('virtual int F() %s {' % virt_specifier, error_message)
1725 self.TestLint('int F() override final', error_message)
1726 self.TestLint('int F() override final;', error_message)
1727 self.TestLint('int F() override final {}', error_message)
1728 self.TestLint('int F() final override', error_message)
1729 self.TestLint('int F() final override;', error_message)
1730 self.TestLint('int F() final override {}', error_message)
1748 self.TestLint('void Finalize(AnnotationProto *final) override;', '')
1755 self.TestLint('var = sctime_r()', '')
1756 self.TestLint('var = strtok_r()', '')
1757 self.TestLint('var = strtok_r(foo, ba, r)', '')
1758 self.TestLint('var = brand()', '')
1759 self.TestLint('_rand()', '')
1760 self.TestLint('.rand()', '')
1761 self.TestLint('->rand()', '')
1762 self.TestLint('ACMRandom rand(seed)', '')
1763 self.TestLint('ISAACRandom rand()', '')
1764 self.TestLint('var = rand()',
1768 self.TestLint('var = strtok(str, delim)',
1775 self.TestLint('VLOG(1)', '')
1776 self.TestLint('VLOG(99)', '')
1777 self.TestLint('LOG(ERROR)', '')
1778 self.TestLint('LOG(INFO)', '')
1779 self.TestLint('LOG(WARNING)', '')
1780 self.TestLint('LOG(FATAL)', '')
1781 self.TestLint('LOG(DFATAL)', '')
1782 self.TestLint('VLOG(SOMETHINGWEIRD)', '')
1783 self.TestLint('MYOWNVLOG(ERROR)', '')
1787 self.TestLint('VLOG(ERROR)', errmsg)
1788 self.TestLint('VLOG(INFO)', errmsg)
1789 self.TestLint('VLOG(WARNING)', errmsg)
1790 self.TestLint('VLOG(FATAL)', errmsg)
1791 self.TestLint('VLOG(DFATAL)', errmsg)
1792 self.TestLint(' VLOG(ERROR)', errmsg)
1793 self.TestLint(' VLOG(INFO)', errmsg)
1794 self.TestLint(' VLOG(WARNING)', errmsg)
1795 self.TestLint(' VLOG(FATAL)', errmsg)
1796 self.TestLint(' VLOG(DFATAL)', errmsg)
1801 self.TestLint('printf("foo")', '')
1802 self.TestLint('printf("foo: %s", foo)', '')
1803 self.TestLint('DocidForPrintf(docid)', '') # Should not trigger.
1804 self.TestLint('printf(format, value)', '') # Should not trigger.
1805 self.TestLint('printf(__VA_ARGS__)', '') # Should not trigger.
1806 self.TestLint('printf(format.c_str(), value)', '') # Should not trigger.
1807 self.TestLint('printf(format(index).c_str(), value)', '')
1808 self.TestLint(
1812 self.TestLint(
1817 self.TestLint(
1822 self.TestLint(
1832 self.TestLint('void operator=(const Myclass&)', '')
1833 self.TestLint('void operator&(int a, int b)', '') # binary operator& ok
1834 self.TestLint('void operator&() { }', errmsg)
1835 self.TestLint('void operator & ( ) { }',
1857 self.TestLint('void f(const string&)', '')
1858 self.TestLint('const string& f(const string& a, const string& b)', '')
1859 self.TestLint('typedef const string& A;', '')
1862 self.TestLint(decl + ' = b;', '')
1863 self.TestLint(decl + ' =', '')
1868 self.TestLint(decl + ';', errmsg)
1876 self.TestLint('int a[any_old_variable];', errmsg)
1877 self.TestLint('int doublesize[some_var * 2];', errmsg)
1878 self.TestLint('int a[afunction()];', errmsg)
1879 self.TestLint('int a[function(kMaxFooBars)];', errmsg)
1880 self.TestLint('bool a_list[items_->size()];', errmsg)
1881 self.TestLint('namespace::Type buffer[len+1];', errmsg)
1883 self.TestLint('int a[64];', '')
1884 self.TestLint('int a[0xFF];', '')
1885 self.TestLint('int first[256], second[256];', '')
1886 self.TestLint('int array_name[kCompileTimeConstant];', '')
1887 self.TestLint('char buf[somenamespace::kBufSize];', '')
1888 self.TestLint('int array_name[ALL_CAPS];', '')
1889 self.TestLint('AClass array1[foo::bar::ALL_CAPS];', '')
1890 self.TestLint('int a[kMaxStrLen + 1];', '')
1891 self.TestLint('int a[sizeof(foo)];', '')
1892 self.TestLint('int a[sizeof(*foo)];', '')
1893 self.TestLint('int a[sizeof foo];', '')
1894 self.TestLint('int a[sizeof(struct Foo)];', '')
1895 self.TestLint('int a[128 - sizeof(const bar)];', '')
1896 self.TestLint('int a[(sizeof(foo) * 4)];', '')
1897 self.TestLint('int a[(arraysize(fixed_size_array)/2) << 1];', '')
1898 self.TestLint('delete a[some_var];', '')
1899 self.TestLint('return a[some_var];', '')
1980 self.TestLint('int a[3] = { 1, 2, 3 };', '')
1981 self.TestLint(
2003 self.TestLint('CHECK(x == 42);',
2006 self.TestLint('CHECK(x != 42);',
2009 self.TestLint('CHECK(x >= 42);',
2012 self.TestLint('CHECK(x > 42);',
2015 self.TestLint('CHECK(x <= 42);',
2018 self.TestLint('CHECK(x < 42);',
2022 self.TestLint('DCHECK(x == 42);',
2025 self.TestLint('DCHECK(x != 42);',
2028 self.TestLint('DCHECK(x >= 42);',
2031 self.TestLint('DCHECK(x > 42);',
2034 self.TestLint('DCHECK(x <= 42);',
2037 self.TestLint('DCHECK(x < 42);',
2041 self.TestLint(
2045 self.TestLint(
2049 self.TestLint(
2054 self.TestLint(
2058 self.TestLint(
2062 self.TestLint(
2066 self.TestLint(
2070 self.TestLint(
2075 self.TestLint('CHECK(x<42);',
2080 self.TestLint('CHECK(x>42);',
2086 self.TestLint('using some::namespace::operator<<;', '')
2087 self.TestLint('using some::namespace::operator>>;', '')
2089 self.TestLint('CHECK(x->y == 42);',
2093 self.TestLint(
2097 self.TestLint(
2105 self.TestLint('CHECK(4\'2 == x);',
2110 self.TestLint('CHECK(some_iterator == obj.end());', '')
2111 self.TestLint('EXPECT_TRUE(some_iterator == obj.end());', '')
2112 self.TestLint('EXPECT_FALSE(some_iterator == obj.end());', '')
2113 self.TestLint('CHECK(some_pointer != NULL);', '')
2114 self.TestLint('EXPECT_TRUE(some_pointer != NULL);', '')
2115 self.TestLint('EXPECT_FALSE(some_pointer != NULL);', '')
2117 self.TestLint('CHECK(CreateTestFile(dir, (1 << 20)));', '')
2118 self.TestLint('CHECK(CreateTestFile(dir, (1 >> 20)));', '')
2120 self.TestLint('CHECK(x ^ (y < 42));', '')
2121 self.TestLint('CHECK((x > 42) ^ (x < 54));', '')
2122 self.TestLint('CHECK(a && b < 42);', '')
2123 self.TestLint('CHECK(42 < a && a < b);', '')
2124 self.TestLint('SOFT_CHECK(x > 42);', '')
2140 self.TestLint('CHECK(x < 42) << "Custom error message";', '')
2144 self.TestLint('true or true',
2147 self.TestLint('true and true',
2150 self.TestLint('if (not true)',
2153 self.TestLint('1 bitor 1',
2156 self.TestLint('1 xor 1',
2159 self.TestLint('1 bitand 1',
2162 self.TestLint('x = compl 1',
2165 self.TestLint('x and_eq y',
2168 self.TestLint('x or_eq y',
2171 self.TestLint('x xor_eq y',
2174 self.TestLint('x not_eq y',
2177 self.TestLint('line_continuation or',
2180 self.TestLint('if(true and(parentheses',
2184 self.TestLint('#include "base/false-and-false.h"', '')
2185 self.TestLint('#error false or false', '')
2186 self.TestLint('false nor false', '')
2187 self.TestLint('false nand false', '')
2196 self.TestLint('bool operator>(Foo& s, Foo& f);',
2199 self.TestLint('bool operator+(Foo& s, Foo& f);',
2202 self.TestLint('int len(Foo& s);', operand_error_message % 'Foo& s')
2204 self.TestLint('stream& operator>>(stream& s, Foo& f);', '')
2205 self.TestLint('stream& operator<<(stream& s, Foo& f);', '')
2206 self.TestLint('void swap(Bar& a, Bar& b);', '')
2207 self.TestLint('ostream& LogFunc(ostream& s);', '')
2208 self.TestLint('ostringstream& LogFunc(ostringstream& s);', '')
2209 self.TestLint('istream& LogFunc(istream& s);', '')
2210 self.TestLint('istringstream& LogFunc(istringstream& s);', '')
2212 self.TestLint('int& g();', '')
2214 self.TestLint('void foo(const struct tm& tm);', '')
2216 self.TestLint('void foo(const typename tm& tm);', '')
2218 self.TestLint('void foo(const Bar* const& p) {', '')
2219 self.TestLint('void foo(Bar const* const& p) {', '')
2220 self.TestLint('void foo(Bar* const& p) {', '')
2222 self.TestLint('void foo(const std::vector<std::string>& v);', '')
2224 self.TestLint('void foo(Bar*& p);',
2226 self.TestLint('void foo(const Bar*& p);',
2228 self.TestLint('void foo(Bar const*& p);',
2230 self.TestLint('void foo(struct Bar*& p);',
2232 self.TestLint('void foo(const struct Bar*& p);',
2234 self.TestLint('void foo(struct Bar const*& p);',
2237 self.TestLint('void foo(std::vector<int>& p);',
2240 self.TestLint('return &something;', '')
2241 self.TestLint('if (condition) {return &something; }', '')
2242 self.TestLint('if (condition) return &something;', '')
2243 self.TestLint('if (condition) address = &something;', '')
2244 self.TestLint('if (condition) result = lhs&rhs;', '')
2245 self.TestLint('if (condition) result = lhs & rhs;', '')
2246 self.TestLint('a = (b+c) * sizeof &f;', '')
2247 self.TestLint('a = MySize(b) * sizeof &f;', '')
2249 self.TestLint('for (const string& s : c)', '')
2250 self.TestLint('for (auto& r : c)', '')
2251 self.TestLint('for (typename Type& a : b)', '')
2253 self.TestLint('T& operator=(const T& t);', '')
2254 self.TestLint('int g() { return (a & b); }', '')
2255 self.TestLint('T& r = (T&)*(vp());', '')
2256 self.TestLint('T& r = v', '')
2257 self.TestLint('static_assert((kBits & kMask) == 0, "text");', '')
2258 self.TestLint('COMPILE_ASSERT((kBits & kMask) == 0, text);', '')
2261 self.TestLint('void Func(const vector <int> &const_x, '
2266 self.TestLint('void Func(X& x);', operand_error_message % 'X& x')
2267 self.TestLint('void Func(X& x) {}', operand_error_message % 'X& x')
2268 self.TestLint('void Func(X& x) override;', '')
2269 self.TestLint('void Func(X& x) override {', '')
2270 self.TestLint('void Func(X& x) const override;', '')
2271 self.TestLint('void Func(X& x) const override {', '')
2274 self.TestLint('void NS::Func(X& x) {', '')
2374 self.TestLint('{',
2413 self.TestLint('if (foo ) {', 'Mismatching spaces inside () in if'
2415 self.TestLint('switch ( foo) {', 'Mismatching spaces inside () in switch'
2417 self.TestLint('for (foo; ba; bar ) {', 'Mismatching spaces inside () in for'
2419 self.TestLint('for (; foo; bar) {', '')
2420 self.TestLint('for ( ; foo; bar) {', '')
2421 self.TestLint('for ( ; foo; bar ) {', '')
2422 self.TestLint('for (foo; bar; ) {', '')
2423 self.TestLint('while ( foo ) {', 'Should have zero or one spaces inside'
2427 self.TestLint('if (foo) {', '')
2428 self.TestLint('for (foo; bar; baz) {', '')
2429 self.TestLint('for (;;) {', '')
2431 self.TestLint('Something* p = new (place) Something();', '')
2433 self.TestLint('for (foo; baz;) {', '')
2434 self.TestLint('for (foo;bar;baz) {', 'Missing space after ;'
2437 self.TestLint('if (condition) {return &something; }',
2440 self.TestLint('DoSth();\\', '')
2442 self.TestLint('abc;// this is abc',
2445 self.TestLint('while (foo) {', '')
2446 self.TestLint('switch (foo) {', '')
2447 self.TestLint('foo( bar)', 'Extra space after ( in function call'
2449 self.TestLint('foo( // comment', '')
2450 self.TestLint('foo( // comment',
2453 self.TestLint('foobar( \\', '')
2454 self.TestLint('foobar( \\', '')
2455 self.TestLint('( a + b)', 'Extra space after ('
2457 self.TestLint('((a+b))', '')
2458 self.TestLint('foo (foo)', 'Extra space before ( in function call'
2461 self.TestLint('asm volatile ("")', '')
2462 self.TestLint('__asm__ __volatile__ ("")', '')
2463 self.TestLint('} catch (const Foo& ex) {', '')
2464 self.TestLint('case (42):', '')
2465 self.TestLint('typedef foo (*foo)(foo)', '')
2466 self.TestLint('typedef foo (*foo12bar_)(foo)', '')
2467 self.TestLint('typedef foo (Foo::*bar)(foo)', '')
2468 self.TestLint('using foo = type (Foo::*bar)(foo)', '')
2469 self.TestLint('using foo = type (Foo::*bar)(', '')
2470 self.TestLint('using foo = type (Foo::*)(', '')
2471 self.TestLint('foo (Foo::*bar)(', '')
2472 self.TestLint('foo (x::y::*z)(', '')
2473 self.TestLint('foo (Foo::bar)(',
2476 self.TestLint('foo (*bar)(', '')
2477 self.TestLint('typedef foo (Foo::*bar)(', '')
2478 self.TestLint('(foo)(bar)', '')
2479 self.TestLint('Foo (*foo)(bar)', '')
2480 self.TestLint('Foo (*foo)(Bar bar,', '')
2481 self.TestLint('char (*p)[sizeof(foo)] = &foo', '')
2482 self.TestLint('char (&ref)[sizeof(foo)] = &foo', '')
2483 self.TestLint('const char32 (*table[])[6];', '')
2488 self.TestLint('sizeof(foo)', '')
2489 self.TestLint('sizeof foo', '')
2490 self.TestLint('sizeof (foo)', '')
2493 self.TestLint('if (foo){', 'Missing space before {'
2495 self.TestLint('for{', 'Missing space before {'
2497 self.TestLint('for {', '')
2498 self.TestLint('EXPECT_DEBUG_DEATH({', '')
2499 self.TestLint('std::is_convertible<A, B>{}', '')
2500 self.TestLint('blah{32}', 'Missing space before {'
2502 self.TestLint('int8_t{3}', '')
2503 self.TestLint('int16_t{3}', '')
2504 self.TestLint('int32_t{3}', '')
2505 self.TestLint('uint64_t{12345}', '')
2506 self.TestLint('constexpr int64_t kBatchGapMicros ='
2508 self.TestLint('MoveOnly(int i1, int i2) : ip1{new int{i1}}, '
2513 self.TestLint('if (cond) { func(); };',
2515 self.TestLint('void Func() {};',
2517 self.TestLint('void Func() const {};',
2519 self.TestLint('class X {};', '')
2524 self.TestLint(keyword + align + typename + ' {}' + identifier + ';',
2527 self.TestLint('class X : public Y {};', '')
2528 self.TestLint('class X : public MACRO() {};', '')
2529 self.TestLint('class X : public decltype(expr) {};', '')
2530 self.TestLint('DEFINE_FACADE(PCQueue::Watcher, PCQueue) {};', '')
2531 self.TestLint('VCLASS(XfaTest, XfaContextTest) {};', '')
2532 self.TestLint('class STUBBY_CLASS(H, E) {};', '')
2533 self.TestLint('class STUBBY2_CLASS(H, E) {};', '')
2534 self.TestLint('TEST(TestCase, TestName) {};',
2536 self.TestLint('TEST_F(TestCase, TestName) {};',
2539 self.TestLint('file_tocs_[i] = (FileToc) {a, b, c};', '')
2543 self.TestLint('auto x = []() {};', '')
2544 self.TestLint('return []() {};', '')
2546 self.TestLint('int operator[](int x) {};',
2561 self.TestLint('table_to_children[&*table].push_back(dependent);', '')
2564 self.TestLint('MyStruct p = {1, 2};', '')
2565 self.TestLint('MyStruct p{1, 2};', '')
2566 self.TestLint('vector<int> p = {1, 2};', '')
2567 self.TestLint('vector<int> p{1, 2};', '')
2568 self.TestLint('x = vector<int>{1, 2};', '')
2569 self.TestLint('x = (struct in_addr){ 0 };', '')
2570 self.TestLint('Func(vector<int>{1, 2})', '')
2571 self.TestLint('Func((struct in_addr){ 0 })', '')
2572 self.TestLint('Func(vector<int>{1, 2}, 3)', '')
2573 self.TestLint('Func((struct in_addr){ 0 }, 3)', '')
2574 self.TestLint('LOG(INFO) << char{7};', '')
2575 self.TestLint('LOG(INFO) << char{7} << "!";', '')
2576 self.TestLint('int p[2] = {1, 2};', '')
2577 self.TestLint('return {1, 2};', '')
2578 self.TestLint('std::unique_ptr<Foo> foo{new Foo{}};', '')
2579 self.TestLint('auto foo = std::unique_ptr<Foo>{new Foo{}};', '')
2580 self.TestLint('static_assert(Max7String{}.IsValid(), "");', '')
2581 self.TestLint('map_of_pairs[{1, 2}] = 3;', '')
2582 self.TestLint('ItemView{has_offer() ? new Offer{offer()} : nullptr', '')
2583 self.TestLint('template <class T, EnableIf<::std::is_const<T>{}> = 0>', '')
2601 self.TestLint('const pair<string, string> kCL' +
2618 self.TestLint('}else {', 'Missing space before else'
2620 self.TestLint('} else{', 'Missing space before {'
2622 self.TestLint('} else {', '')
2623 self.TestLint('} else if (foo) {', '')
2626 self.TestLint('int v[1][3] = {{1, 2, 3}};', '')
2627 self.TestLint('int v[1][1] = {{0}};', '')
2630 self.TestLint('if (foo||bar) {', 'Missing spaces around ||'
2632 self.TestLint('if (foo<=bar) {', 'Missing spaces around <='
2634 self.TestLint('if (foo<bar) {', 'Missing spaces around <'
2636 self.TestLint('if (foo>bar) {', 'Missing spaces around >'
2638 self.TestLint('if (foo<bar->baz) {', 'Missing spaces around <'
2640 self.TestLint('if (foo<bar->bar) {', 'Missing spaces around <'
2642 self.TestLint('template<typename T = double>', '')
2643 self.TestLint('std::unique_ptr<No<Spaces>>', '')
2644 self.TestLint('typedef hash_map<Foo, Bar>', '')
2645 self.TestLint('10<<20', '')
2646 self.TestLint('10<<a',
2648 self.TestLint('a<<20',
2650 self.TestLint('a<<b',
2652 self.TestLint('10LL<<20', '')
2653 self.TestLint('10ULL<<20', '')
2654 self.TestLint('a>>b',
2656 self.TestLint('10>>b',
2658 self.TestLint('LOG(ERROR)<<*foo',
2660 self.TestLint('LOG(ERROR)<<&foo',
2662 self.TestLint('StringCoder<vector<string>>::ToString()', '')
2663 self.TestLint('map<pair<int, int>, map<int, int>>::iterator', '')
2664 self.TestLint('func<int, pair<int, pair<int, int>>>()', '')
2665 self.TestLint('MACRO1(list<list<int>>)', '')
2666 self.TestLint('MACRO2(list<list<int>>, 42)', '')
2667 self.TestLint('void DoFoo(const set<vector<string>>& arg1);', '')
2668 self.TestLint('void SetFoo(set<vector<string>>* arg1);', '')
2669 self.TestLint('foo = new set<vector<string>>;', '')
2670 self.TestLint('reinterpret_cast<set<vector<string>>*>(a);', '')
2671 self.TestLint('MACRO(<<)', '')
2672 self.TestLint('MACRO(<<, arg)', '')
2673 self.TestLint('MACRO(<<=)', '')
2674 self.TestLint('MACRO(<<=, arg)', '')
2676 self.TestLint('using Vector3<T>::operator==;', '')
2677 self.TestLint('using Vector3<T>::operator!=;', '')
2680 self.TestLint('call_function() ;',
2684 self.TestLint('while (true) ;',
2688 self.TestLint('default:;',
2691 self.TestLint(' ;',
2695 self.TestLint('for (int i = 0; ;', '')
2698 self.TestLint('while (true);',
2701 self.TestLint('if (true);',
2704 self.TestLint('while (true)', '')
2705 self.TestLint('while (true) continue;', '')
2706 self.TestLint('for (;;);',
2709 self.TestLint('for (;;)', '')
2710 self.TestLint('for (;;) continue;', '')
2711 self.TestLint('for (;;) func();', '')
2712 self.TestLint('if (test) {}',
2715 self.TestLint('if (test) func();', '')
2716 self.TestLint('if (test) {} else {}', '')
2744 self.TestLint('if (test) { hello; }', '')
2745 self.TestLint('if (test({})) { hello; }', '')
2769 self.TestLint('for (int i : numbers) {', '')
2772 self.TestLint('for (int i: numbers) {',
2776 self.TestLint('for (int i :numbers) {',
2780 self.TestLint('for (int i:numbers) {',
2785 self.TestLint('for (std::size_t i : sizes) {}', '')
2787 self.TestLint('for (std::size_t i: sizes) {}',
2802 self.TestLint('string foo;',
2804 self.TestLint('string kFoo = "hello"; // English',
2806 self.TestLint('static string foo;',
2808 self.TestLint('static const string foo;',
2810 self.TestLint('static const std::string foo;',
2812 self.TestLint('string Foo::bar;',
2815 self.TestLint('std::string foo;',
2817 self.TestLint('std::string kFoo = "hello"; // English',
2819 self.TestLint('static std::string foo;',
2821 self.TestLint('static const std::string foo;',
2823 self.TestLint('std::string Foo::bar;',
2826 self.TestLint('::std::string foo;',
2828 self.TestLint('::std::string kFoo = "hello"; // English',
2830 self.TestLint('static ::std::string foo;',
2832 self.TestLint('static const ::std::string foo;',
2834 self.TestLint('::std::string Foo::bar;',
2837 self.TestLint('string* pointer', '')
2838 self.TestLint('string *pointer', '')
2839 self.TestLint('string* pointer = Func();', '')
2840 self.TestLint('string *pointer = Func();', '')
2841 self.TestLint('const string* pointer', '')
2842 self.TestLint('const string *pointer', '')
2843 self.TestLint('const string* pointer = Func();', '')
2844 self.TestLint('const string *pointer = Func();', '')
2845 self.TestLint('string const* pointer', '')
2846 self.TestLint('string const *pointer', '')
2847 self.TestLint('string const* pointer = Func();', '')
2848 self.TestLint('string const *pointer = Func();', '')
2849 self.TestLint('string* const pointer', '')
2850 self.TestLint('string *const pointer', '')
2851 self.TestLint('string* const pointer = Func();', '')
2852 self.TestLint('string *const pointer = Func();', '')
2853 self.TestLint('string Foo::bar() {}', '')
2854 self.TestLint('string Foo::operator*() {}', '')
2856 self.TestLint('string foo("foobar");', nonconst_error_msg)
2858 self.TestLint(' string foo', '')
2860 self.TestLint('string EmptyString() { return ""; }', '')
2861 self.TestLint('string EmptyString () { return ""; }', '')
2862 self.TestLint('string const& FileInfo::Pathname() const;', '')
2863 self.TestLint('string const &FileInfo::Pathname() const;', '')
2864 self.TestLint('string VeryLongNameFunctionSometimesEndsWith(\n'
2866 self.TestLint('template<>\n'
2869 self.TestLint('template<>\n'
2874 self.TestLint('string Class<Type>::Method() const {\n'
2877 self.TestLint('string Class<Type>::Method(\n'
2914 self.TestLint('TellStory(1, 3);',
2916 self.TestLint('TellStory(1, 3 );',
2919 self.TestLint('TellStory(1 /* wolf */, 3 /* pigs */);',
2944 self.TestLint('// TODOfix this',
2946 self.TestLint('// TODO(ljenkins)fix this',
2948 self.TestLint('// TODO fix this',
2950 self.TestLint('// TODO fix this', missing_username)
2951 self.TestLint('// TODO: fix this', missing_username)
2952 self.TestLint('//TODO(ljenkins): Fix this',
2955 self.TestLint('// TODO(ljenkins):Fix this', end_space)
2956 self.TestLint('// TODO(ljenkins):', '')
2957 self.TestLint('// TODO(ljenkins): fix this', '')
2958 self.TestLint('// TODO(ljenkins): Fix this', '')
2959 self.TestLint('#if 1 // TEST_URLTODOCID_WHICH_HAS_THAT_WORD_IN_IT_H_', '')
2960 self.TestLint('// See also similar TODO above', '')
2961 self.TestLint(r'EXPECT_EQ("\\", '
2966 self.TestLint('} // namespace foo',
2969 self.TestLint('}// namespace foo',
2972 self.TestLint('printf("foo"); // Outside quotes.',
2975 self.TestLint('int i = 0; // Having two spaces is fine.', '')
2976 self.TestLint('int i = 0; // Having three spaces is OK.', '')
2977 self.TestLint('// Top level comment', '')
2978 self.TestLint(' // Line starts with two spaces.', '')
2996 self.TestLint('if (foo) { // not a pure scope; comment is too close!',
2999 self.TestLint('printf("// In quotes.")', '')
3000 self.TestLint('printf("\\"%s // In quotes.")', '')
3001 self.TestLint('printf("%s", "// In quotes.")', '')
3004 self.TestLint('//', '')
3005 self.TestLint('//x', 'Should have a space between // and comment'
3007 self.TestLint('// x', '')
3008 self.TestLint('///', '')
3009 self.TestLint('/// x', '')
3010 self.TestLint('//!', '')
3011 self.TestLint('//----', '')
3012 self.TestLint('//====', '')
3013 self.TestLint('//////', '')
3014 self.TestLint('////// x', '')
3015 self.TestLint('///< x', '') # After-member Doxygen comment
3016 self.TestLint('//!< x', '') # After-member Doxygen comment
3017 self.TestLint('////x', 'Should have a space between // and comment'
3019 self.TestLint('//}', '')
3020 self.TestLint('//}x', 'Should have a space between // and comment'
3022 self.TestLint('//!<x', 'Should have a space between // and comment'
3024 self.TestLint('///<x', 'Should have a space between // and comment'
3389 self.TestLint(' else DoSomethingElse();',
3392 self.TestLint(' else ifDoSomethingElse();',
3395 self.TestLint(' } else if (blah) {', '')
3396 self.TestLint(' variable_ends_in_else = true;', '')
3399 self.TestLint('a = f(1,2);',
3401 self.TestLint('int tmp=a,a=b,b=tmp;',
3404 self.TestLint('f(a, /* name */ b);', '')
3405 self.TestLint('f(a, /* name */b);', '')
3406 self.TestLint('f(a, /* name */-1);', '')
3407 self.TestLint('f(a, /* name */"1");', '')
3408 self.TestLint('f(1, /* empty macro arg */, 2)', '')
3409 self.TestLint('f(1,, 2)', '')
3410 self.TestLint('operator,()', '')
3411 self.TestLint('operator,(a,b)',
3415 self.TestLint('int tmp= a;',
3417 self.TestLint('int tmp =a;',
3419 self.TestLint('int tmp=a;',
3421 self.TestLint('int tmp= 7;',
3423 self.TestLint('int tmp =7;',
3425 self.TestLint('int tmp=7;',
3427 self.TestLint('int* tmp=*p;',
3429 self.TestLint('int* tmp= *p;',
3436 self.TestLint('bool result = a>=42;',
3438 self.TestLint('bool result = a<=42;',
3440 self.TestLint('bool result = a==42;',
3442 self.TestLint('auto result = a!=42;',
3444 self.TestLint('int a = b!=c;',
3446 self.TestLint('a&=42;', '')
3447 self.TestLint('a|=42;', '')
3448 self.TestLint('a^=42;', '')
3449 self.TestLint('a+=42;', '')
3450 self.TestLint('a*=42;', '')
3451 self.TestLint('a/=42;', '')
3452 self.TestLint('a%=42;', '')
3453 self.TestLint('a>>=5;', '')
3454 self.TestLint('a<<=5;', '')
3457 self.TestLint('a<<b',
3459 self.TestLint('a>>b',
3461 self.TestLint('1<<20', '')
3462 self.TestLint('1024>>10', '')
3463 self.TestLint('Kernel<<<1, 2>>>()', '')
3466 self.TestLint('static int noindent;', '')
3467 self.TestLint(' int two_space_indent;', '')
3468 self.TestLint(' int four_space_indent;', '')
3469 self.TestLint(' int one_space_indent;',
3472 self.TestLint(' int three_space_indent;',
3475 self.TestLint(' char* one_space_indent = "public:";',
3478 self.TestLint(' public:', '')
3479 self.TestLint(' protected:', '')
3480 self.TestLint(' private:', '')
3481 self.TestLint(' protected: \\', '')
3482 self.TestLint(' public: \\', '')
3483 self.TestLint(' private: \\', '')
3778 self.TestLint('\tint a;',
3780 self.TestLint('int a = 5;\t\t// set a to 5',
3870 self.TestLint(
3873 self.TestLint(
3878 self.TestLint(
3881 self.TestLint(
3892 self.TestLint(
3896 self.TestLint('int a = (int)1.0;', '')
3897 self.TestLint(' weird opening space', '')
3908 self.TestLint('// Hello there ', '')
3910 self.TestLint(
3914 self.TestLint(' weird opening space', '')
4010 self.TestLint('class Foo::Goo;',
4331 self.TestLint('#include "foo.h"',
4334 self.TestLint('#include "Python.h"', '')
4335 self.TestLint('#include "lua.h"', '')
4364 self.TestLint(
4369 self.TestLint(
4374 self.TestLint(
4379 self.TestLint(
4384 self.TestLint(
4389 self.TestLint(
4414 self.TestLint('const int static foo = 5;',
4417 self.TestLint('char static foo;',
4420 self.TestLint('double const static foo = 2.0;',
4423 self.TestLint('uint64 typedef unsigned_long_long;',
4426 self.TestLint('int register foo = 0;',
4503 self.TestLint('*count++;',
4508 self.TestLint('vsnprintf(NULL, 0, format)', '')
4509 self.TestLint('snprintf(fisk, 1, format)',
4576 self.TestLint('make_pair', '')
4577 self.TestLint('make_pair(42, 42)', '')
4578 self.TestLint('make_pair<',
4583 self.TestLint('make_pair <',
4588 self.TestLint('my_make_pair<int, int>', '')