Exemplo n.º 1
0
    def setUp(self):

        ast = parse('./test_data/c_files/valid.c',
                    ['-E', r'-Ipycreviewer/utils/fake_libc_include'])
        sourcecode_valid = SourceCode(ast)
        ast = parse('./test_data/c_files/none.c',
                    ['-E', r'-Ipycreviewer/utils/fake_libc_include'])
        sourcecode_none = SourceCode(ast)
        conditions = CheckConditions('./test_data/default.json')
        self.rules_valid = CodinfgRules(sourcecode_valid, conditions)
        self.rules_none = CodinfgRules(sourcecode_none, conditions)
Exemplo n.º 2
0
 def test_SearchRecursiveFunctionCall_None(self):
     target = SourceCode(self.none_ast)
     steps = target.SearchRecursiveFunctionCall()
     self.assertEqual(steps, [])
Exemplo n.º 3
0
 def test_SearchRecursiveFunctionCall_valid(self):
     target = SourceCode(self.valid_ast)
     funccalls = target.SearchRecursiveFunctionCall()
     self.assertEqual(len(funccalls), 6)
     example = funccalls[0]
     self.assertEqual(example.name, 'g_function_def1')
Exemplo n.º 4
0
 def test_SearchFunctionCalls_none(self):
     target = SourceCode(self.none_ast)
     funccalls = target.SearchFunctionCalls('free')
     self.assertEqual(len(funccalls), 0)
Exemplo n.º 5
0
 def test_DefinedFunctions_None(self):
     target = SourceCode(self.none_ast)
     functions = target.DefinedFunctions()
     self.assertEqual(functions, [])
Exemplo n.º 6
0
 def test_DefinedFunctions_valid(self):
     target = SourceCode(self.valid_ast)
     functions = target.DefinedFunctions()
     self.assertEqual(len(functions), 2)
     example = functions[0]
     self.assertEqual(example.name, 'g_function_def1')
Exemplo n.º 7
0
 def test_Variables_none(self):
     target = SourceCode(self.none_ast)
     variables = target.Varialbles()
     self.assertEqual(len(variables), 0)
Exemplo n.º 8
0
 def test_GlobalValiables_None(self):
     target = SourceCode(self.none_ast)
     valiables = target.GlobalValiables()
     self.assertEqual(valiables, [])
Exemplo n.º 9
0
 def test_GlobalValiables_valid(self):
     target = SourceCode(self.valid_ast)
     valiables = target.GlobalValiables()
     self.assertEqual(len(valiables), 3)
     example = valiables[0]
     self.assertEqual(example.name, 'g_int_val1')
Exemplo n.º 10
0
 def test_SearchNoDefaultInSwitch_none(self):
     target = SourceCode(self.none_ast)
     cases = target.SearchNoDefaultInSwitch()
     self.assertEqual(cases, [])
Exemplo n.º 11
0
 def test_SearchNoDefaultInSwitch_valid(self):
     target = SourceCode(self.valid_ast)
     cases = target.SearchNoDefaultInSwitch()
     self.assertEqual(len(cases), 1)
Exemplo n.º 12
0
 def test_SearchNoBreakInCase_none(self):
     target = SourceCode(self.none_ast)
     cases = target.SearchNoBreakInCase()
     self.assertEqual(cases, [])
Exemplo n.º 13
0
 def test_SearchNoBreakInCase_valid(self):
     target = SourceCode(self.valid_ast)
     cases = target.SearchNoBreakInCase()
     self.assertEqual(len(cases), 1)