summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppquickfix_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 5969e36d9b..0bd5554f22 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -1178,6 +1178,58 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
data.run(&factory);
}
+/// Check if whitespace is respected for operator functions
+void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1()
+{
+ QByteArray original =
+ "class Foo\n"
+ "{\n"
+ " Foo &opera@tor =();\n"
+ "};\n";
+ QByteArray expected =
+ "class Foo\n"
+ "{\n"
+ " Foo &operator =();\n"
+ "};\n"
+ "\n"
+ "\n"
+ "Foo &Foo::operator =()\n"
+ "{\n"
+ "\n"
+ "}\n"
+ "\n";
+
+ InsertDefFromDecl factory;
+ TestCase data(original, expected);
+ data.run(&factory);
+}
+
+/// Check if whitespace is respected for operator functions
+void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2()
+{
+ QByteArray original =
+ "class Foo\n"
+ "{\n"
+ " Foo &opera@tor=();\n"
+ "};\n";
+ QByteArray expected =
+ "class Foo\n"
+ "{\n"
+ " Foo &operator=();\n"
+ "};\n"
+ "\n"
+ "\n"
+ "Foo &Foo::operator=()\n"
+ "{\n"
+ "\n"
+ "}\n"
+ "\n";
+
+ InsertDefFromDecl factory;
+ TestCase data(original, expected);
+ data.run(&factory);
+}
+
// Function for one of InsertDeclDef section cases
void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
{
@@ -2458,6 +2510,52 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
data.run(&factory, 1);
}
+/// Check if whitespace is respected for operator functions
+void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1()
+{
+ QByteArray original =
+ "class Foo\n"
+ "{\n"
+ " Foo &opera@tor =() {}\n"
+ "};\n";
+ QByteArray expected =
+ "class Foo\n"
+ "{\n"
+ " Foo &operator =();\n"
+ "};\n"
+ "\n"
+ "\n"
+ "Foo &Foo::operator =() {}\n"
+ "\n";
+
+ MoveFuncDefOutside factory;
+ TestCase data(original, expected);
+ data.run(&factory);
+}
+
+/// Check if whitespace is respected for operator functions
+void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2()
+{
+ QByteArray original =
+ "class Foo\n"
+ "{\n"
+ " Foo &opera@tor=() {}\n"
+ "};\n";
+ QByteArray expected =
+ "class Foo\n"
+ "{\n"
+ " Foo &operator=();\n"
+ "};\n"
+ "\n"
+ "\n"
+ "Foo &Foo::operator=() {}\n"
+ "\n";
+
+ MoveFuncDefOutside factory;
+ TestCase data(original, expected);
+ data.run(&factory);
+}
+
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
{