コード例 #1
0
class TestLicenseHeader(UnitTest):
    def test_create_replacement_rules(self):
        self.assert_equals({"year_": str(datetime.now().year)},
                           LicenseHeader.create_replacement_rules())

    def test_instantiate(self):
        self.instance = LicenseHeader(self.fake_template).instantiate()
        for token, value in LicenseHeader.create_replacement_rules().items():
            self.assert_string_does_not_contain(self.instance, token)
            self.assert_string_contains(self.instance, value)

    def test_instantiate_for_cmakelists(self):
        self.instance = LicenseHeader(
            self.fake_template).instantiate_for_cmakelists()
        for line in self.instance.splitlines():
            self.assert_true(self.instance.startswith("# "))
        self.assert_true(self.instance.endswith("\n\n"))

    def test_instantiate_for_cpp(self):
        self.instance = LicenseHeader(self.fake_template).instantiate_for_cpp()
        self.assert_true(self.instance.startswith("/* "))
        self.assert_true(self.instance.endswith(" */\n\n"))

    def setUp(self):
        self.fake_template = "year_"
コード例 #2
0
 def setUp(self):
     self.namespace_begin = "namespace Fake {"
     self.namespace_end = "} /* Fake */"
     self.class_name = "arbitrary_name"
     self.interface_name = "interface_name"
     self.fake_template = self.namespace_begin + " CLASS_NAME_ class_name_ { }; " + self.namespace_end
     self.fake_interface = (
         self.namespace_begin + "\nclass " + self.interface_name +
         " {\nvirtual void method1() = 0;\nvirtual void method2() = 0;\n};\n"
         + self.namespace_end)
     self.fake_raw_header = "};"
     self.fake_license_header = LicenseHeader("arbitrary license (year_)")
コード例 #3
0
 def create_license_header(self):
     return LicenseHeader(File.read(self.path.to_license_header_template))
コード例 #4
0
 def create_license_header(self):
     return LicenseHeader(File.read(self.path.to_license_header_template)
                          ).instantiate_for_cmakelists()
コード例 #5
0
 def setUp(self):
     self.fake_template = "class_name_"
     self.fake_license_header = LicenseHeader("arbitrary license (year_)")
     self.class_name = "arbitrary_name"
コード例 #6
0
 def test_instantiate_for_cpp(self):
     self.instance = LicenseHeader(self.fake_template).instantiate_for_cpp()
     self.assert_true(self.instance.startswith("/* "))
     self.assert_true(self.instance.endswith(" */\n\n"))
コード例 #7
0
 def test_instantiate_for_cmakelists(self):
     self.instance = LicenseHeader(
         self.fake_template).instantiate_for_cmakelists()
     for line in self.instance.splitlines():
         self.assert_true(self.instance.startswith("# "))
     self.assert_true(self.instance.endswith("\n\n"))
コード例 #8
0
 def test_instantiate(self):
     self.instance = LicenseHeader(self.fake_template).instantiate()
     for token, value in LicenseHeader.create_replacement_rules().items():
         self.assert_string_does_not_contain(self.instance, token)
         self.assert_string_contains(self.instance, value)
コード例 #9
0
 def test_create_replacement_rules(self):
     self.assert_equals({"year_": str(datetime.now().year)},
                        LicenseHeader.create_replacement_rules())
コード例 #10
0
 def setUp(self):
     self.fake_template = "class_name_\n"
     self.fake_header = "virtual void method1() = 0;\nvirtual void method2() = 0;\n"
     self.fake_license_header = LicenseHeader("arbitrary license (year_)")
     self.class_name = "arbitrary_name"
コード例 #11
0
 def setUp(self):
     self.fake_template = "CLASS_NAME_ class_name_ { };"
     self.class_name = "arbitrary_name"
     self.fake_raw_header = "};"
     self.fake_license_header = LicenseHeader("arbitrary license (year_)")