def create(self):
     path = self.path.to_include_directory / (self.class_name + ".h")
     template = InterfaceHeader(
         File.read(self.path.to_class_header_template),
         self.create_license_header())
     File.write(self.path.to_include_directory / (self.class_name + ".h"),
                template.instantiate_with(self.class_name))
 def test_instantiate_with(self):
     instance = InterfaceHeader(self.fake_template,
                                self.fake_license_header).instantiate_with(
                                    self.class_name)
     self.assert_string_contains(instance,
                                 "virtual ~" + self.class_name + "() {}")
     self.assert_string_contains(
         instance, "//virtual return_type_ method_name_(input_type_) = 0;")
Ejemplo n.º 3
0
 def add_methods(header, interface):
     class_end = "};"
     header = header.replace(class_end, "\n" + class_end)
     for method in InterfaceHeader.extract_methods(interface):
         header = header.replace(
             class_end,
             ImplementationHeader.create_signature(method) + class_end)
     return header
Ejemplo n.º 4
0
 def add_interface_header(header, interface):
     project_name = InterfaceHeader.extract_project_name(interface)
     interface_name = InterfaceHeader.extract_interface_name(interface)
     include = "#include <" + project_name + "/" + interface_name + ".h>\n"
     return header.replace("namespace", include + "\nnamespace")
Ejemplo n.º 5
0
 def add_content_to(self, bare_tests, class_name):
     for method in InterfaceHeader.extract_methods(self.header):
         bare_tests += self.create_test_case(method, class_name)
     return bare_tests
 def test_extract_methods(self):
     fake_interface_header = "    virtual void method1() = 0;\nvirtual void method2() = 0;\n"
     self.assert_equals(
         ["void method1()", "void method2()"],
         InterfaceHeader.extract_methods(fake_interface_header))
 def test_extract_project_name(self):
     fake_interface_header = "namespace Fake {\n"
     self.assert_equals(
         "Fake",
         InterfaceHeader.extract_project_name(fake_interface_header))
 def test_extract_interface_name(self):
     fake_interface_header = "class " + self.class_name + " {\n\n};\n"
     self.assert_equals(
         self.class_name,
         InterfaceHeader.extract_interface_name(fake_interface_header))