(self)
| 2422 | |
| 2423 | # Brace usage |
| 2424 | def testBraces(self): |
| 2425 | # Braces shouldn't be followed by a ; unless they're defining a struct |
| 2426 | # or initializing an array |
| 2427 | self.TestLint("int a[3] = { 1, 2, 3 };", "") |
| 2428 | self.TestLint( |
| 2429 | """const int foo[] = |
| 2430 | {1, 2, 3 };""", |
| 2431 | "", |
| 2432 | ) |
| 2433 | # For single line, unmatched '}' with a ';' is ignored (not enough context) |
| 2434 | self.TestMultiLineLint( |
| 2435 | """int a[3] = { 1, |
| 2436 | 2, |
| 2437 | 3 };""", |
| 2438 | "", |
| 2439 | ) |
| 2440 | self.TestMultiLineLint( |
| 2441 | """int a[2][3] = { { 1, 2 }, |
| 2442 | { 3, 4 } };""", |
| 2443 | "", |
| 2444 | ) |
| 2445 | self.TestMultiLineLint( |
| 2446 | """int a[2][3] = |
| 2447 | { { 1, 2 }, |
| 2448 | { 3, 4 } };""", |
| 2449 | "", |
| 2450 | ) |
| 2451 | self.TestMultiLineLint( # should not claim else should have braces on both sides |
| 2452 | """if (foo) { |
| 2453 | bar; |
| 2454 | } |
| 2455 | else { |
| 2456 | baz; |
| 2457 | }""", |
| 2458 | "An else should appear on the same line as the preceding } [whitespace/newline] [4]", |
| 2459 | ) |
| 2460 | |
| 2461 | # CHECK/EXPECT_TRUE/EXPECT_FALSE replacements |
| 2462 | def testCheckCheck(self): |
nothing calls this directly
no test coverage detected