Beispiel #1
0
    def test_add_param_at_index_test2(self):
        source = 'outer_function<template>(a, b, c, fun(g, h), d, e)'
        result = 'outer_function<template>(a,b,c,c1,fun(g, h),d,e)'

        pattern = 'template' + " *>? *\("
        self.assertEqual(
            CPPSourceCodePorter.add_param_at_index(source, pattern, 'c1', 3),
            result)
Beispiel #2
0
    def setUpClass(cls):
        cls.mapping = Utilities.get_consolidated_mapping()

        ast_dict = {
            AstConstants.NON_UNIT_TEST:
            Utilities.read_json_file(
                os.path.join("porting_tools", "test",
                             "ast_dump_lex_node.json"))
        }
        cls.ast_line_wise = Utilities.store_ast_line_by_line(
            ast_dict[AstConstants.NON_UNIT_TEST])

        cls.file_path_in_ast = LEX_NODE_FILE_LIST[2]
        cls.cpp_porter = CPPSourceCodePorter(ast_dict, cls.file_path_in_ast)
Beispiel #3
0
    def setUpClass(cls):
        cls.mapping = Utilities.get_consolidated_mapping()

        ast_dict = {
            AstConstants.NON_UNIT_TEST:
            Utilities.read_json_file(
                os.path.join("porting_tools", "test",
                             "ast_dump_talker_cpp.json"))
        }
        cls.ast_line_wise = Utilities.store_ast_line_by_line(
            ast_dict[AstConstants.NON_UNIT_TEST])

        # file_path as mentioned in the `ast_dump_talker_cpp.json` file, will not be used for file reading purpose
        # as the path is system specific
        cls.file_path_in_ast = "src/talker/talker.cpp"
        cls.cpp_porter = CPPSourceCodePorter(ast_dict, cls.file_path_in_ast)
Beispiel #4
0
 def test_add_param_at_index_test1(self):
     source = 'outer_function(a, b, c, fun(g, h), d, e)'
     result = 'outer_function(a,b,c,c1,fun(g, h),d,e)'
     self.assertEqual(
         CPPSourceCodePorter.add_param_at_index(source, "outer_function\(",
                                                'c1', 3), result)
Beispiel #5
0
 def test_add_param_at_index_test0(self):
     source = 'outer_function(a, b, c, fun(), d, e)'
     result = 'outer_function(a, b, c, fun(g0), d, e)'
     self.assertEqual(
         CPPSourceCodePorter.add_param_at_index(source, "fun\(", 'g0', 0),
         result)
Beispiel #6
0
 def test_get_range_for_replacement_without_another_funcall_param(self):
     source = 'outer_function(a, b, c, fun(g, h), d, e)'
     result = (24, 32)
     self.assertEqual(
         CPPSourceCodePorter.get_range_for_replacement(source, "fun\("),
         result)
Beispiel #7
0
 def test_get_line_token_with_new_arg_1(self):
     source = ["ros", "::", "spinOnce", "(", ")"]
     result = ["ros", "::", "spinOnce", "(", "param0", ")"]
     self.assertEqual(
         CPPSourceCodePorter.get_line_token_with_new_arg(
             source, 0, "param0"), result)