class CppStubHeaderUpdateTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_header_update_add_namespace(self): self.cpp_file.parse_header("namespace test{namespace test1{}}") updated_code = self.cpp_file.update_header_code_string("namespace test{}") self.assertEquals("namespace test{\n\nnamespace test1\n{\n\n}\n\n}", updated_code) def test_header_update_add_function_in_namespace(self): self.cpp_file.parse_header("namespace test{void test1();}") updated_code = self.cpp_file.update_header_code_string("namespace test{}") self.assertEquals("namespace test{\n\nvoid test1();\n\n}", updated_code) def test_header_update_add_function_in_namespace_with_function(self): self.cpp_file.parse_header("namespace test{void test2();}") updated_code = self.cpp_file.update_header_code_string("namespace test{void test1();}") self.assertEquals("namespace test{void test1();\n\nvoid test2();\n\n}", updated_code) def test_header_update_add_constructor_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test();};}") updated_code = self.cpp_file.update_header_code_string("namespace test{class Test{};}") self.assertEquals("namespace test{class Test{\n\npublic:\n\n Test();\n\n};\n\n}", updated_code) def test_header_update_add_constructor_in_class_in_namespace_with_function(self): self.cpp_file.parse_header("namespace test{class Test{public:Test();};}") updated_code = self.cpp_file.update_header_code_string("namespace test{class Test{public:void test1();};}") self.assertEquals("namespace test{class Test{public:\n\n Test();\n\nvoid test1();\n\n};\n\n}", updated_code) def test_header_update_add_private_method_in_class_in_namespace_with_function(self): self.cpp_file.parse_header("namespace test{class Test{private:void test2();};}") updated_code = self.cpp_file.update_header_code_string("namespace test{class Test{public:void test1();};}") self.assertEquals( "namespace test{class Test{public:void test1();\n\nprivate:\n\n void test2();\n\n};\n\n}", updated_code )
def setUp(self): self.cpp_file = CppFile("TestSuite")
class CppStubHeaderOutputTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_header_output_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) self.cpp_file.namespaces.append(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n}\n\n", self.cpp_file.header()) def test_header_output_namespace_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_namespace1 = CppNamespace("test1", cpp_namespace) cpp_namespace.namespaces.append(cpp_namespace1) self.cpp_file.namespaces.append(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\nnamespace test1\n{\n\n}\n\n}\n\n", self.cpp_file.header()) def test_header_output_multiple_namespaces(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_namespace1 = CppNamespace("test1", self.cpp_file) self.cpp_file.namespaces.append(cpp_namespace) self.cpp_file.namespaces.append(cpp_namespace1) self.assertEquals("\n\nnamespace test\n{\n\n}\n\nnamespace test1\n{\n\n}\n\n", self.cpp_file.header()) def test_header_output_function_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_function = CppMethod("test1", [], "void", cpp_namespace) cpp_namespace.methods.append(cpp_function) self.cpp_file.namespaces.append(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\nvoid test1();\n\n}\n\n", self.cpp_file.header()) def test_header_output_constructor_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("Test", [], None, cpp_class) cpp_class.methods["public"].append(cpp_method) self.cpp_file.namespaces.append(cpp_namespace) cpp_namespace.classes.append(cpp_class) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\npublic:\n\n Test();\n\n};\n\n}\n\n", self.cpp_file.header() ) def test_header_output_private_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "void", cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n void test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_private_access_const_return_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_method.const_return_type = True cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n const int test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_private_access_virtual_const_return_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_method.const_return_type = True cpp_method.virtual = True cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n virtual const int test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_static_return_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_method.static = True cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n static int test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_public_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_class.add_method(cpp_method, "public") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\npublic:\n\n int test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_protected_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_class.add_method(cpp_method, "protected") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprotected:\n\n int test1();\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_method_with_return_type_and_arguments_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", ["int argument"], "int", cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n int test1(int argument);\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_method_with_different_return_type_and_multiple_arguments_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method = CppMethod("test1", ["int argument1", "std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n std::string test1(int argument1, std::string argument2);\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_multiple_methods_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method1 = CppMethod("test1", ["int argument1"], "int", cpp_class) cpp_method2 = CppMethod("test2", ["std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method1, "private") cpp_class.add_method(cpp_method2, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\nprivate:\n\n int test1(int argument1);\n\n std::string test2(std::string argument2);\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_multiple_access_multiple_methods_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent=cpp_namespace) cpp_method1 = CppMethod("test1", ["int argument1"], "int", cpp_class) cpp_method2 = CppMethod("test2", ["std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method1, "public") cpp_class.add_method(cpp_method2, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test\n{\n\npublic:\n\n int test1(int argument1);\n\nprivate:\n\n std::string test2(std::string argument2);\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_private_access_class_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class1 = CppClass("Test1", parent=cpp_namespace) cpp_class2 = CppClass("Test2", parent=cpp_class1) cpp_class1.add_class(cpp_class2, "private") cpp_namespace.add_class(cpp_class1) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test1\n{\n\nprivate:\n\n class Test2\n {\n\n };\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_public_access_class_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class1 = CppClass("Test1", parent=cpp_namespace) cpp_class2 = CppClass("Test2", parent=cpp_class1) cpp_class1.add_class(cpp_class2, "public") cpp_namespace.add_class(cpp_class1) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test1\n{\n\npublic:\n\n class Test2\n {\n\n };\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_protected_access_class_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class1 = CppClass("Test1", parent=cpp_namespace) cpp_class2 = CppClass("Test2", parent=cpp_class1) cpp_class1.add_class(cpp_class2, "protected") cpp_namespace.add_class(cpp_class1) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test1\n{\n\nprotected:\n\n class Test2\n {\n\n };\n\n};\n\n}\n\n", self.cpp_file.header(), ) def test_header_output_template_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test1", parent=cpp_namespace) cpp_class.templated = True cpp_class.template_type = "Test" cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\ntemplate <class Test>\nclass Test1\n{\n\n};\n\n}\n\n", self.cpp_file.header() ) def test_header_output_template_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test1", parent=cpp_namespace) cpp_method = CppMethod("test1", [], "Test&", cpp_class) cpp_method.templated = True cpp_method.template_type = "Test" cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals( "\n\nnamespace test\n{\n\nclass Test1\n{\n\nprivate:\n\n template <class Test>\n Test& test1();\n\n};\n\n}\n\n", self.cpp_file.header(), )
class CppStubCppUpdateTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_cpp_update_add_namespace(self): self.cpp_file.parse_cpp("namespace test{namespace test1{}}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{}") self.assertEquals("namespace test{\n\nnamespace test1\n{\n\n}\n\n}", updated_code) def test_cpp_update_add_function_in_namespace(self): self.cpp_file.parse_cpp("namespace test{void test1(){}}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{}") self.assertEquals("namespace test{\n\nvoid test1()\n{\n\n}\n\n}", updated_code) def test_cpp_update_add_function_in_namespace_with_function(self): self.cpp_file.parse_cpp("namespace test{void test2(){}}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{void test1(){}}") self.assertEquals("namespace test{void test1(){}\n\nvoid test2()\n{\n\n}\n\n}", updated_code) def test_cpp_update_add_constructor_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test::Test(){}};}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{}") self.assertEquals("namespace test{\n\n// unknown\n\nTest::Test()\n{\n\n}\n\n}", updated_code) def test_cpp_update_add_constructor_in_class_in_namespace_with_function(self): self.cpp_file.parse_cpp("namespace test{Test::Test(){}}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{void Test::test1(){}}") self.assertEquals("namespace test{void Test::test1(){}\n\n// unknown\n\nTest::Test()\n{\n\n}\n\n}", updated_code) def test_cpp_update_add_private_method_in_class_in_namespace_with_function(self): self.cpp_file.parse_cpp("namespace test{void Test::test2(){}}") updated_code = self.cpp_file.update_cpp_code_string("namespace test{void Test::test1(){}}") self.assertEquals("namespace test{void Test::test1(){}\n\n// unknown\n\nvoid Test::test2()\n{\n\n}\n\n}", updated_code)
class CppStubCppOutputTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_cpp_output_namespace(self): self.cpp_file.namespaces.append(CppNamespace("test", self.cpp_file)) self.assertEquals("\n\nnamespace test\n{\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_namespace_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_namespace1 = CppNamespace("test1", cpp_namespace) cpp_namespace.namespaces.append(cpp_namespace1) self.cpp_file.namespaces.append(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\nnamespace test1\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_multiple_namespaces(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_namespace1 = CppNamespace("test1", cpp_namespace) self.cpp_file.namespaces.append(cpp_namespace) self.cpp_file.namespaces.append(cpp_namespace1) self.assertEquals("\n\nnamespace test\n{\n\n}\n\nnamespace test1\n{\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_function_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_function = CppMethod("test1", [], "void", cpp_namespace) cpp_namespace.methods.append(cpp_function) self.cpp_file.namespaces.append(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\nvoid test1()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_constructor_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("Test", [], None, cpp_class) cpp_class.methods["public"].append(cpp_method) self.cpp_file.namespaces.append(cpp_namespace) cpp_namespace.classes.append(cpp_class) self.assertEquals("\n\nnamespace test\n{\n\n// public\n\nTest::Test()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_private_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", [], "void", parent = cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nvoid Test::test1()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_private_access_const_return_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_method.const_return_type = True cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nconst int Test::test1()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_public_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_class.add_method(cpp_method, "public") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// public\n\nint Test::test1()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_protected_access_method_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", [], "int", cpp_class) cpp_class.add_method(cpp_method, "protected") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// protected\n\nint Test::test1()\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_method_with_return_type_and_arguments_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", ["int argument"], "int", cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nint Test::test1(int argument)\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_method_with_different_return_type_and_multiple_arguments_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method = CppMethod("test1", ["int argument1", "std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nstd::string Test::test1(int argument1, std::string argument2)\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_multiple_methods_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method1 = CppMethod("test1", ["int argument1"], "int", cpp_class) cpp_method2 = CppMethod("test2", ["std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method1, "private") cpp_class.add_method(cpp_method2, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nint Test::test1(int argument1)\n{\n\n}\n\nstd::string Test::test2(std::string argument2)\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_multiple_access_multiple_methods_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class = CppClass("Test", parent = cpp_namespace) cpp_method1 = CppMethod("test1", ["int argument1"], "int", cpp_class) cpp_method2 = CppMethod("test2", ["std::string argument2"], "std::string", cpp_class) cpp_class.add_method(cpp_method1, "public") cpp_class.add_method(cpp_method2, "private") cpp_namespace.add_class(cpp_class) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// public\n\nint Test::test1(int argument1)\n{\n\n}\n\n// private\n\nstd::string Test::test2(std::string argument2)\n{\n\n}\n\n}\n\n", self.cpp_file.cpp()) def test_cpp_output_private_access_method_in_class_in_class_in_namespace(self): cpp_namespace = CppNamespace("test", self.cpp_file) cpp_class1 = CppClass("Test1", parent = cpp_namespace) cpp_class2 = CppClass("Test2", parent = cpp_class1) cpp_method = CppMethod("test1", ["int argument1"], "int", cpp_class2) cpp_class2.add_method(cpp_method, "private") cpp_class1.add_class(cpp_class2, "private") cpp_namespace.add_class(cpp_class1) self.cpp_file.add_namespace(cpp_namespace) self.assertEquals("\n\nnamespace test\n{\n\n// private\n\nint Test1::Test2::test1(int argument1)\n{\n\n}\n\n}\n\n", self.cpp_file.cpp())
class CppStubHeaderParsingTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_header_parse_namespace(self): self.cpp_file.parse_header("namespace test{}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") def test_header_parse_namespace_in_namespace(self): self.cpp_file.parse_header("namespace test{namespace test1{}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].namespaces[0].name, "test1") def test_header_parse_multiple_namespaces(self): self.cpp_file.parse_header("namespace test{}namespace test1{}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[1].name, "test1") def test_header_parse_function_in_namespace(self): self.cpp_file.parse_header("namespace test{void test1();}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test1") def test_header_parse_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") def test_header_parse_class_with_inherited_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test : Test1{};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].inherited_classes[0], "Test1") def test_header_parse_class_with_multiple_inherited_classes_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test : Test1, Test2{};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].inherited_classes[0], "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].inherited_classes[1], "Test2") def test_header_parse_constructor_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test(class own_t *sink_);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "Test") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 1) def test_header_parse_constructor_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test(){function();};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "Test") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 1) #operators split and ordered via http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B def test_header_parse_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test& operator=(const Test& rhs){function();}Test operator+(const Test& rhs) const {function();}Test operator-(const Test& rhs) const {function();}Test operator+() const {function();}Test operator-() const{function();}Test operator*(const Test& rhs) const {function();}Test operator/(const Test& rhs) const {function();}Test operator%(const Test& rhs) const {function();}Test& operator++(){function();}Test operator++(int){function();}Test& operator--(){function();}Test operator--(int){function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator+") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator-") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator+") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator-") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][5].name, "operator*") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][5].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][6].name, "operator/") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][6].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][7].name, "operator%") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][7].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][8].name, "operator++") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][9].name, "operator++") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][10].name, "operator--") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][11].name, "operator--") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 12) def test_header_parse_comparison_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:bool operator==(const Test& rhs) const{function();};bool operator!=(const Test& rhs) const {function();}bool operator>(const Test& rhs) const {function();}bool operator<(const Test& rhs) const {function();}bool operator>=(const Test& rhs) const {function();}bool operator<=(const Test& rhs) const {function();};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator==") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator!=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator>") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator<") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator>=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][5].name, "operator<=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][5].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 6) def test_header_parse_logical_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:bool operator!() const{function();}bool operator&&(const Test& rhs) const {function();}bool operator||(const Test& rhs) const {function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator!") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator&&") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator||") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][2].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 3) def test_header_parse_bitwise_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test operator~() const{function();}Test operator&(const Test& rhs) const {function();}Test operator|(const Test& rhs) const {function();}Test operator^(const Test& rhs) const {function();}Test operator<<(const Test& rhs) const {function();}Test operator>>(const Test& rhs) const {function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator~") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator&") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator|") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator^") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator<<") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][5].name, "operator>>") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][5].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 6) def test_header_parse_compound_assignment_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test& operator+=(const Test& rhs){function();}Test& operator-=(const Test& rhs){function();}Test& operator*=(const Test& rhs){function();}Test& operator/=(const Test& rhs){function();}Test& operator%=(const Test& rhs){function();}Test& operator&=(const Test& rhs){function();}Test& operator|=(const Test& rhs){function();}Test& operator^=(const Test& rhs){function();}Test& operator<<=(const Test& rhs){function();}Test& operator>>=(const Test& rhs){function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator+=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator-=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator*=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator/=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator%=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][5].name, "operator&=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][6].name, "operator|=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][7].name, "operator^=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][8].name, "operator<<=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][9].name, "operator>>=") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 10) def test_header_parse_member_and_pointer_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test2& operator[](const Test1& rhs){function();}Test2& operator*(){function();}Test* operator&(){function();}Test1* operator->(){function();}Test1 operator->*(){function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator[]") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator&") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator->") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator->*") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 5) def test_header_parse_other_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:Test1 operator()(Arg1 a1, Arg2 a2){function();}Test1& operator,(Test1& rhs) const {function();}void* operator new(size_t x){function();}void* operator new[](size_t x){function();}void operator delete(void* x){function();}void operator delete[](void* x){function();}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "operator()") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][1].name, "operator,") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["public"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][2].name, "operator new") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][3].name, "operator new[]") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][4].name, "operator delete") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][5].name, "operator delete[]") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["public"]), 6) def test_header_parse_default_access_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{void test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") def test_header_parse_default_access_const_return_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{const int test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][0].const_return_type) def test_header_parse_default_access_virtual_const_return_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{virtual const int test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][0].const_return_type) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][0].virtual) def test_header_parse_static_return_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{static int test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][0].static) def test_header_parse_private_access_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{private:void test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") def test_header_parse_public_access_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:void test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "test1") def test_header_parse_protected_access_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{protected:void test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["protected"][0].name, "test1") def test_header_parse_method_with_return_type_and_arguments_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{int test1(int argument);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "int argument") def test_header_parse_method_with_different_return_type_and_multiple_arguments_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{std::string test1(int argument1, std::string argument2);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[1], "std::string argument2") def test_header_parse_multiple_methods_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{int test1(int argument1);std::string test2(std::string argument2);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[0], "std::string argument2") def test_header_parse_multiple_access_multiple_methods_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{public:int test1(int argument1);private:std::string test2(std::string argument2);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "std::string argument2") def test_header_parse_multiple_access_including_default_multiple_methods_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{private:int test1(int argument1);public:std::string test2(std::string argument2);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["public"][0].method_arguments[0], "std::string argument2") def test_header_parse_implemented_method_with_return_type_and_arguments_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{int test1(int argument1);std::string test2(std::string argument2){}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "int argument1") self.assertFalse(self.cpp_file.namespaces[0].classes[0].methods["private"][0].implemented) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[0], "std::string argument2") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][1].implemented) def test_header_parse_default_access_class_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test1{class Test2{};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["private"][0].name, "Test2") def test_header_parse_private_access_class_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test1{private:class Test2{};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["private"][0].name, "Test2") def test_header_parse_public_access_class_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test1{public:class Test2{};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["public"][0].name, "Test2") def test_header_parse_protected_access_class_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test1{protected:class Test2{};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["protected"][0].name, "Test2") def test_header_parse_method_with_reference_return_type_and_reference_arguments_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{std::string& test1(std::string& argument1, std::string &argument2, std::string & argument3);char &test2(char& argument4, char &argument5,char & argument6);int & test3(int& argument7, int &argument8, int & argument9);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string&") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "std::string& argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[1], "std::string &argument2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[2], "std::string & argument3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].return_type, "char &") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[0], "char& argument4") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[1], "char &argument5") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[2], "char & argument6") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].return_type, "int &") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[0], "int& argument7") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[1], "int &argument8") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[2], "int & argument9") def test_header_parse_method_with_pointer_return_type_and_pointer_arguments_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{std::string* test1(std::string* argument1, std::string *argument2, std::string * argument3);char *test2(char* argument4, char *argument5,char * argument6);int * test3(int* argument7, int *argument8, int * argument9);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "std::string* argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[1], "std::string *argument2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[2], "std::string * argument3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].return_type, "char *") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[0], "char* argument4") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[1], "char *argument5") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[2], "char * argument6") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].return_type, "int *") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[0], "int* argument7") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[1], "int *argument8") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[2], "int * argument9") def test_header_parse_method_with_pointer_return_type_and_array_argument_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{std::string* test1(std::string argument[]);};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "std::string argument[]") def test_header_parse_virtual_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test{std::string test1(std::string argument1);virtual int test2(int argument2);virtual int test3(int argument3){};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].method_arguments[0], "std::string argument1") self.assertFalse(self.cpp_file.namespaces[0].classes[0].methods["private"][0].virtual) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][1].method_arguments[0], "int argument2") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][1].virtual) self.assertFalse(self.cpp_file.namespaces[0].classes[0].methods["private"][1].implemented) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].return_type, "int") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][2].method_arguments[0], "int argument3") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][2].virtual) self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][2].implemented) def test_header_parse_template_class_in_namespace(self): self.cpp_file.parse_header("namespace test{template <class Test>class Test1{};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertTrue(self.cpp_file.namespaces[0].classes[0].templated) self.assertEquals(self.cpp_file.namespaces[0].classes[0].template_type, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") def test_header_parse_template_method_in_class_in_namespace(self): self.cpp_file.parse_header("namespace test{class Test1{template <class Test> Test& test1();};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test1") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["private"][0].templated) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].template_type, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["private"][0].name, "test1")
class CppStubCppParsingTestSuite(unittest.TestCase): def setUp(self): self.cpp_file = CppFile("TestSuite") def test_parse_cpp_namespace(self): self.cpp_file.parse_cpp("namespace test{}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") def test_parse_cpp_multiple_namespaces(self): self.cpp_file.parse_cpp("namespace test{}namespace test1{}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[1].name, "test1") def test_parse_cpp_namespace_in_namespace(self): self.cpp_file.parse_cpp("namespace test{namespace test1{}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].namespaces[0].name, "test1") def test_parse_cpp_method_in_namespace(self): self.cpp_file.parse_cpp("namespace test{test(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test") def test_parse_cpp_multiple_methods_in_namespace(self): self.cpp_file.parse_cpp("namespace test{test1(){}test2(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].methods[1].name, "test2") def test_parse_cpp_class_method_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test::test(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test") def test_parse_cpp_multiple_class_methods_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test::test(){}Test::test1(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "test1") def test_parse_cpp_multiple_classes_methods_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test::test(){}Test1::test1(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[1].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[1].methods["unknown"][0].name, "test1") def test_parse_cpp_mutiple_class_method_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test::Test1::test(){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["unknown"][0].name, "Test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].classes["unknown"][0].methods["unknown"][0].name, "test") def test_parse_cpp_class_method_with_return_type_and_argument_in_namespace(self): self.cpp_file.parse_cpp("namespace test{void Test::test(int argument){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].return_type, "void") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[0], "int argument") def test_parse_cpp_class_method_with_different_return_type_and_multiple_arguments_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string Test::test(int argument1, std::string argument2){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].return_type, "std::string") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[1], "std::string argument2") def test_parse_cpp_method(self): self.cpp_file.parse_cpp("test(){}") self.assertEquals(self.cpp_file.methods[0].name, "test") def test_parse_cpp_class_method(self): self.cpp_file.parse_cpp("Test::test(){}") self.assertEquals(self.cpp_file.classes[0].name, "Test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].name, "test") def test_parse_cpp_multiple_class_methods(self): self.cpp_file.parse_cpp("Test::test(){}Test::test1(){}") self.assertEquals(self.cpp_file.classes[0].name, "Test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][1].name, "test1") def test_parse_cpp_multiple_classes_methods(self): self.cpp_file.parse_cpp("Test::test(){}Test1::test1(){}") self.assertEquals(self.cpp_file.classes[0].name, "Test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.classes[1].name, "Test1") self.assertEquals(self.cpp_file.classes[1].methods["unknown"][0].name, "test1") def test_parse_cpp_mutiple_class_method(self): self.cpp_file.parse_cpp("Test::Test1::test(){}") self.assertEquals(self.cpp_file.classes[0].name, "Test") self.assertEquals(self.cpp_file.classes[0].classes["unknown"][0].name, "Test1") self.assertEquals(self.cpp_file.classes[0].classes["unknown"][0].methods["unknown"][0].name, "test") def test_parse_cpp_class_method_with_return_type_and_argument(self): self.cpp_file.parse_cpp("void Test::test(int argument){}") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].return_type, "void") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].method_arguments[0], "int argument") def test_parse_cpp_class_method_with_different_return_type_and_multiple_arguments(self): self.cpp_file.parse_cpp("std::string Test::test(int argument1, std::string argument2){}") self.assertEquals(self.cpp_file.classes[0].name, "Test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].name, "test") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].return_type, "std::string") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.classes[0].methods["unknown"][0].method_arguments[1], "std::string argument2") def test_parse_cpp_multiple_methods(self): self.cpp_file.parse_cpp("test1(){}test2(){}") self.assertEquals(self.cpp_file.methods[0].name, "test1") self.assertEquals(self.cpp_file.methods[1].name, "test2") def test_parse_cpp_class_method_with_reference_return_type_and_reference_arguments_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string& Test::test1(std::string& argument1, std::string &argument2, std::string & argument3){}char &Test::test2(char& argument4, char &argument5, char & argument6){}int & Test::test3(int& argument7, int &argument8, int & argument9){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].return_type, "std::string&") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[0], "std::string& argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[1], "std::string &argument2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[2], "std::string & argument3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].return_type, "char &") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[0], "char& argument4") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[1], "char &argument5") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[2], "char & argument6") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].return_type, "int &") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[0], "int& argument7") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[1], "int &argument8") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[2], "int & argument9") def test_parse_cpp_class_method_with_pointer_return_type_and_pointer_arguments_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string* Test::test1(std::string* argument1, std::string *argument2, std::string * argument3){}char *Test::test2(char* argument4, char *argument5, char * argument6){}int * Test::test3(int* argument7, int *argument8, int * argument9){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[0], "std::string* argument1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[1], "std::string *argument2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[2], "std::string * argument3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].return_type, "char *") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[0], "char* argument4") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[1], "char *argument5") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].method_arguments[2], "char * argument6") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].return_type, "int *") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[0], "int* argument7") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[1], "int *argument8") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].method_arguments[2], "int * argument9") def test_parse_cpp_class_method_with_pointer_return_type_and_array_argument_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string* Test::test1(std::string argument[]){}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].method_arguments[0], "std::string argument[]") def test_parse_cpp_method_with_return_type_and_argument(self): self.cpp_file.parse_cpp("void test(int argument){}") self.assertEquals(self.cpp_file.methods[0].name, "test") self.assertEquals(self.cpp_file.methods[0].return_type, "void") self.assertEquals(self.cpp_file.methods[0].method_arguments[0], "int argument") def test_parse_cpp_method_with_different_return_type_and_multiple_arguments(self): self.cpp_file.parse_cpp("std::string test(int argument1, std::string argument2){}") self.assertEquals(self.cpp_file.methods[0].name, "test") self.assertEquals(self.cpp_file.methods[0].return_type, "std::string") self.assertEquals(self.cpp_file.methods[0].method_arguments[0], "int argument1") self.assertEquals(self.cpp_file.methods[0].method_arguments[1], "std::string argument2") def test_parse_cpp_method_with_reference_return_type_and_reference_arguments_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string& test1(std::string& argument1, std::string &argument2, std::string & argument3){}char &test2(char& argument4, char &argument5, char & argument6){}int & test3(int& argument7, int &argument8, int & argument9){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].methods[0].return_type, "std::string&") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[0], "std::string& argument1") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[1], "std::string &argument2") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[2], "std::string & argument3") self.assertEquals(self.cpp_file.namespaces[0].methods[1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].methods[1].return_type, "char &") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[0], "char& argument4") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[1], "char &argument5") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[2], "char & argument6") self.assertEquals(self.cpp_file.namespaces[0].methods[2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].methods[2].return_type, "int &") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[0], "int& argument7") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[1], "int &argument8") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[2], "int & argument9") def test_parse_cpp_method_with_pointer_return_type_and_pointer_arguments_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string* test1(std::string* argument1, std::string *argument2, std::string * argument3){}char *test2(char* argument4, char *argument5, char * argument6){}int * test3(int* argument7, int *argument8, int * argument9){}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].methods[0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[0], "std::string* argument1") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[1], "std::string *argument2") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[2], "std::string * argument3") self.assertEquals(self.cpp_file.namespaces[0].methods[1].name, "test2") self.assertEquals(self.cpp_file.namespaces[0].methods[1].return_type, "char *") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[0], "char* argument4") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[1], "char *argument5") self.assertEquals(self.cpp_file.namespaces[0].methods[1].method_arguments[2], "char * argument6") self.assertEquals(self.cpp_file.namespaces[0].methods[2].name, "test3") self.assertEquals(self.cpp_file.namespaces[0].methods[2].return_type, "int *") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[0], "int* argument7") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[1], "int *argument8") self.assertEquals(self.cpp_file.namespaces[0].methods[2].method_arguments[2], "int * argument9") def test_parse_cpp_method_with_pointer_return_type_and_array_argument_in_namespace(self): self.cpp_file.parse_cpp("namespace test{std::string* test1(std::string argument[]){}};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].methods[0].name, "test1") self.assertEquals(self.cpp_file.namespaces[0].methods[0].return_type, "std::string*") self.assertEquals(self.cpp_file.namespaces[0].methods[0].method_arguments[0], "std::string argument[]") def test_parse_cpp_method_with_reference_return_type_and_reference_arguments(self): self.cpp_file.parse_cpp("std::string& test1(std::string& argument1, std::string &argument2, std::string & argument3){}char &test2(char& argument4, char &argument5, char & argument6){}int & test3(int& argument7, int &argument8, int & argument9){}") self.assertEquals(self.cpp_file.methods[0].name, "test1") self.assertEquals(self.cpp_file.methods[0].return_type, "std::string&") self.assertEquals(self.cpp_file.methods[0].method_arguments[0], "std::string& argument1") self.assertEquals(self.cpp_file.methods[0].method_arguments[1], "std::string &argument2") self.assertEquals(self.cpp_file.methods[0].method_arguments[2], "std::string & argument3") self.assertEquals(self.cpp_file.methods[1].name, "test2") self.assertEquals(self.cpp_file.methods[1].return_type, "char &") self.assertEquals(self.cpp_file.methods[1].method_arguments[0], "char& argument4") self.assertEquals(self.cpp_file.methods[1].method_arguments[1], "char &argument5") self.assertEquals(self.cpp_file.methods[1].method_arguments[2], "char & argument6") self.assertEquals(self.cpp_file.methods[2].name, "test3") self.assertEquals(self.cpp_file.methods[2].return_type, "int &") self.assertEquals(self.cpp_file.methods[2].method_arguments[0], "int& argument7") self.assertEquals(self.cpp_file.methods[2].method_arguments[1], "int &argument8") self.assertEquals(self.cpp_file.methods[2].method_arguments[2], "int & argument9") def test_parse_cpp_method_with_pointer_return_type_and_pointer_arguments(self): self.cpp_file.parse_cpp("std::string* test1(std::string* argument1, std::string *argument2, std::string * argument3){}char *test2(char* argument4, char *argument5, char * argument6){}int * test3(int* argument7, int *argument8, int * argument9){}") self.assertEquals(self.cpp_file.methods[0].name, "test1") self.assertEquals(self.cpp_file.methods[0].return_type, "std::string*") self.assertEquals(self.cpp_file.methods[0].method_arguments[0], "std::string* argument1") self.assertEquals(self.cpp_file.methods[0].method_arguments[1], "std::string *argument2") self.assertEquals(self.cpp_file.methods[0].method_arguments[2], "std::string * argument3") self.assertEquals(self.cpp_file.methods[1].name, "test2") self.assertEquals(self.cpp_file.methods[1].return_type, "char *") self.assertEquals(self.cpp_file.methods[1].method_arguments[0], "char* argument4") self.assertEquals(self.cpp_file.methods[1].method_arguments[1], "char *argument5") self.assertEquals(self.cpp_file.methods[1].method_arguments[2], "char * argument6") self.assertEquals(self.cpp_file.methods[2].name, "test3") self.assertEquals(self.cpp_file.methods[2].return_type, "int *") self.assertEquals(self.cpp_file.methods[2].method_arguments[0], "int* argument7") self.assertEquals(self.cpp_file.methods[2].method_arguments[1], "int *argument8") self.assertEquals(self.cpp_file.methods[2].method_arguments[2], "int * argument9") def test_parse_cpp_method_with_pointer_return_type_and_array_argument(self): self.cpp_file.parse_cpp("std::string* test1(std::string argument[]){}}") self.assertEquals(self.cpp_file.methods[0].name, "test1") self.assertEquals(self.cpp_file.methods[0].return_type, "std::string*") self.assertEquals(self.cpp_file.methods[0].method_arguments[0], "std::string argument[]") #operators split and ordered via http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B def test_parse_cpp_arithmetic_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test& Test::operator=(const Test& rhs){function();}Test Test::operator+(const Test& rhs) const {function();}Test Test::operator-(const Test& rhs) const {function();}Test Test::operator+() const {function();}Test Test::operator-() const{function();}Test Test::operator*(const Test& rhs) const {function();}Test Test::operator/(const Test& rhs) const {function();}Test Test::operator%(const Test& rhs) const {function();}Test& Test::operator++(){function();}Test Test::operator++(int){function();}Test& Test::operator--(){function();}Test Test::operator--(int){function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator+") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator-") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator+") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator-") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].name, "operator*") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][6].name, "operator/") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][6].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][7].name, "operator%") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][7].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][8].name, "operator++") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][9].name, "operator++") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][10].name, "operator--") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][11].name, "operator--") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 12) def test_parse_cpp_comparison_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{bool Test::operator==(const Test& rhs) const{function();};bool Test::operator!=(const Test& rhs) const {function();}bool Test::operator>(const Test& rhs) const {function();}bool Test::operator<(const Test& rhs) const {function();}bool Test::operator>=(const Test& rhs) const {function();}bool Test::operator<=(const Test& rhs) const {function();};};}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator==") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator!=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator>") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator<") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator>=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].name, "operator<=") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 6) def test_parse_cpp_logical_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{bool Test::operator!() const{function();}bool Test::operator&&(const Test& rhs) const {function();}bool Test::operator||(const Test& rhs) const {function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator!") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator&&") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator||") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 3) def test_parse_cpp_bitwise_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test Test::operator~() const{function();}Test Test::operator&(const Test& rhs) const {function();}Test Test::operator|(const Test& rhs) const {function();}Test Test::operator^(const Test& rhs) const {function();}Test Test::operator<<(const Test& rhs) const {function();}Test Test::operator>>(const Test& rhs) const {function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator~") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator&") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator|") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator^") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator<<") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].const) self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].name, "operator>>") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].const) self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 6) def test_parse_cpp_compound_assignment_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test& Test::operator+=(const Test& rhs){function();}Test& Test::operator-=(const Test& rhs){function();}Test& Test::operator*=(const Test& rhs){function();}Test& Test::operator/=(const Test& rhs){function();}Test& Test::operator%=(const Test& rhs){function();}Test& Test::operator&=(const Test& rhs){function();}Test& Test::operator|=(const Test& rhs){function();}Test& Test::operator^=(const Test& rhs){function();}Test& Test::operator<<=(const Test& rhs){function();}Test& Test::operator>>=(const Test& rhs){function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator+=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator-=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator*=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator/=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator%=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].name, "operator&=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][6].name, "operator|=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][7].name, "operator^=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][8].name, "operator<<=") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][9].name, "operator>>=") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 10) def test_parse_cpp_member_and_pointer_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test2& Test::operator[](const Test1& rhs){function();}Test2& Test::operator*(){function();}Test* Test::operator&(){function();}Test1* Test::operator->(){function();}Test1 Test::operator->*(){function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator[]") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator*") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator&") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator->") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator->*") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 5) def test_parse_cpp_other_operators_with_function_in_implementation_in_class_in_namespace(self): self.cpp_file.parse_cpp("namespace test{Test1 Test::operator()(Arg1 a1, Arg2 a2){function();}Test1& Test::operator,(Test1& rhs) const {function();}void* Test::operator new(size_t x){function();}void* Test::operator new[](size_t x){function();}void Test::operator delete(void* x){function();}void Test::operator delete[](void* x){function();}}") self.assertEquals(self.cpp_file.namespaces[0].name, "test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].name, "Test") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][0].name, "operator()") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].name, "operator,") self.assertTrue(self.cpp_file.namespaces[0].classes[0].methods["unknown"][1].const) #cannot get the regex working with "operator new" and everything else, Test::operator is a part of the return type for these for cases. self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][2].name, "operator new") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][3].name, "operator new[]") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][4].name, "operator delete") self.assertEquals(self.cpp_file.namespaces[0].classes[0].methods["unknown"][5].name, "operator delete[]") self.assertEquals(len(self.cpp_file.namespaces[0].classes[0].methods["unknown"]), 6)