def test_duplicated_include(self):
     self.__testee = IncludeListGeneratorInternal(
         include_guard_normalizer=IncludeGuardNormalizer(
             use_pragma_once=True),
         config=IncludeListGeneratorConfig(
             use_redundant_include_guards=False,
             include_paths_rel_to_root=True,
             use_pragma_once=True),
         include_rule_checker=NullIncludeRuleChecker(),
         header_exception_mapper=NullHeaderExceptionMapper(),
         header_path_mapper=NullHeaderPathMapper(),
         header_canonical_sorter=StandardGroupCanonicalSorter(),
         include_generation_timestamp=False)
     # skip initial comment line which contains an implementation-specific hash
     self.assertEquals([
         '#include "a/ax.h"', '#include "b/b.h"', '', '#include <string>',
         '// *** end of generated include list', ''
     ],
                       self.__testee.generate_include_directives(
                           "a/a.h", [
                               "a/ax.h",
                               "a/ax.h",
                               "b/b.h",
                               "<string>",
                           ])[1:])
示例#2
0
 def __init__(self, include_guard_normalizer, config):
     self.__decoratee = IncludeListGeneratorInternal(
         include_guard_normalizer=include_guard_normalizer,
         config=config,
         include_rule_checker=config_include_rule_checker,
         header_canonical_sorter=config_header_canonical_sorter,
         header_exception_mapper=config_header_exception_mapper,
         header_path_mapper=config_header_path_mapper,
     )
示例#3
0
class IncludeListGeneratorInternalTest(unittest.TestCase):
    def test1(self):
        self.__testee = IncludeListGeneratorInternal(
            include_guard_normalizer=IncludeGuardNormalizer(
                use_pragma_once=True),
            config=IncludeListGeneratorConfig(
                use_redundant_include_guards=False,
                include_paths_rel_to_root=True,
                use_pragma_once=True),
            include_rule_checker=NullIncludeRuleChecker(),
            header_exception_mapper=NullHeaderExceptionMapper(),
            header_path_mapper=NullHeaderPathMapper(),
            header_canonical_sorter=StandardGroupCanonicalSorter(),
            include_generation_timestamp=False)
        self.assertEquals([
            '// *** list of 3 include directives (1369018009)',
            '#include "a/ax.h"', '#include "b/b.h"', '', '#include <string>',
            '// *** end of generated include list', ''
        ],
                          self.__testee.generate_include_directives(
                              "a/a.h", [
                                  "a/ax.h",
                                  "b/b.h",
                                  "<string>",
                              ]))

    def test_duplicated_include(self):
        self.__testee = IncludeListGeneratorInternal(
            include_guard_normalizer=IncludeGuardNormalizer(
                use_pragma_once=True),
            config=IncludeListGeneratorConfig(
                use_redundant_include_guards=False,
                include_paths_rel_to_root=True,
                use_pragma_once=True),
            include_rule_checker=NullIncludeRuleChecker(),
            header_exception_mapper=NullHeaderExceptionMapper(),
            header_path_mapper=NullHeaderPathMapper(),
            header_canonical_sorter=StandardGroupCanonicalSorter(),
            include_generation_timestamp=False)
        self.assertEquals([
            '// *** list of 3 include directives (1369018009)',
            '#include "a/ax.h"', '#include "b/b.h"', '', '#include <string>',
            '// *** end of generated include list', ''
        ],
                          self.__testee.generate_include_directives(
                              "a/a.h", [
                                  "a/ax.h",
                                  "a/ax.h",
                                  "b/b.h",
                                  "<string>",
                              ]))
示例#4
0
class IncludeListGenerator(ConfigDependent):
    def __init__(self, include_guard_normalizer, config):
        self.__decoratee = IncludeListGeneratorInternal(
            include_guard_normalizer=include_guard_normalizer,
            config=config,
            include_rule_checker=config_include_rule_checker,
            header_canonical_sorter=config_header_canonical_sorter,
            header_exception_mapper=config_header_exception_mapper,
            header_path_mapper=config_header_path_mapper,
        )

    def generate_include_directives(self, repair_path, include_paths):
        return self.__decoratee.generate_include_directives(
            repair_path, include_paths)