test_cppcheck_handler.vader
1 Before: 2 call ale#test#SetDirectory('/testplugin/test/handler') 3 4 After: 5 call ale#test#RestoreDirectory() 6 7 Execute(Basic errors should be handled by cppcheck): 8 call ale#test#SetFilename('test.cpp') 9 10 AssertEqual 11 \ [ 12 \ { 13 \ 'lnum': 974, 14 \ 'col' : 6, 15 \ 'type': 'E', 16 \ 'sub_type': '', 17 \ 'text': 'Array ''n[3]'' accessed at index 3, which is out of bounds.', 18 \ 'code': 'arrayIndexOutOfBounds' 19 \ }, 20 \ { 21 \ 'lnum': 1185, 22 \ 'col' : 10, 23 \ 'type': 'W', 24 \ 'sub_type': 'style', 25 \ 'text': 'The scope of the variable ''indxStr'' can be reduced.', 26 \ 'code': 'variableScope' 27 \ }, 28 \ ], 29 \ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [ 30 \ 'test.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\', 31 \ ' n[3]=3;', 32 \ ' ^', 33 \ 'test.cpp:1185:10: style: The scope of the variable ''indxStr'' can be reduced. [variableScope]\', 34 \ ' char indxStr[16];', 35 \ ' ^', 36 \ ]) 37 38 AssertEqual 39 \ [ 40 \ { 41 \ 'lnum': 974, 42 \ 'col' : 1, 43 \ 'type': 'E', 44 \ 'sub_type': '', 45 \ 'text': 'inconclusive Array ''n[3]'' accessed at index 3, which is out of bounds.', 46 \ 'code': 'arrayIndexOutOfBounds' 47 \ }, 48 \ { 49 \ 'lnum': 1185, 50 \ 'col' : 1, 51 \ 'type': 'W', 52 \ 'sub_type': 'style', 53 \ 'text': 'The scope of the variable ''indxStr'' can be reduced.', 54 \ 'code': 'variableScope' 55 \ }, 56 \ ], 57 \ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [ 58 \ 'test.cpp:974:{column}: error:inconclusive Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\', 59 \ ' n[3]=3;', 60 \ ' ^', 61 \ 'test.cpp:1185:{column}: style:{inconclusive:inconclusive} The scope of the variable ''indxStr'' can be reduced. [variableScope]\', 62 \ ' char indxStr[16];', 63 \ ' ^', 64 \ ]) 65 66 AssertEqual 67 \ [ 68 \ { 69 \ 'lnum': 1, 70 \ 'col' : 16, 71 \ 'type': 'W', 72 \ 'sub_type': 'style', 73 \ 'text': 'misra violation (use --rule-texts=<file> to get proper output)', 74 \ 'code': 'misra-c2012-2.7' 75 \ }, 76 \ ], 77 \ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [ 78 \ 'test.cpp:1:16: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.7]\', 79 \ 'void test( int parm ) {}', 80 \ ' ^', 81 \ ]) 82 83 Execute(Problems from other files should be ignored by cppcheck): 84 call ale#test#SetFilename('test.cpp') 85 86 AssertEqual 87 \ [ 88 \ ], 89 \ ale#handlers#cppcheck#HandleCppCheckFormat(bufnr(''), [ 90 \ 'bar.cpp:974:6: error: Array ''n[3]'' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\', 91 \ ' n[3]=3;', 92 \ ' ^', 93 \ ])