Skip to content

Commit

Permalink
Update Extract Function test cases
Browse files Browse the repository at this point in the history
Restore test case to Extract Function in C file.
Update diffs.
  • Loading branch information
LegalizeAdulthood committed Jan 2, 2024
1 parent ac555a6 commit 7571485
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 337 deletions.
4 changes: 2 additions & 2 deletions RefactorTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_library(refactor-test-cases STATIC
CreateMultiVariableDeclaration.cpp
ExtractConstant.cpp
ExtractFunction.cpp
ExtractFunction2.cpp
ExtractFunction2.c
ExtractMethod.cpp
ExtractParameter.cpp
ExtractVariable.cpp
Expand Down Expand Up @@ -55,7 +55,7 @@ add_library(refactor-test-cases STATIC
${CMAKE_CURRENT_BINARY_DIR}/include/Config.h
)
source_group("Header Files" REGULAR_EXPRESSION ".*\\.h")
source_group("Source Files" REGULAR_EXPRESSION ".*\\.cpp")
source_group("Source Files" REGULAR_EXPRESSION ".*\\.(cpp|c)")
source_group("CMake Template Files" REGULAR_EXPRESSION ".*\\.in")
if("cxx_std_14" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_library(refactor-14 OBJECT RenameCpp14.h RenameCpp14.cpp)
Expand Down
40 changes: 32 additions & 8 deletions RefactorTest/ExtractFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ int TestInteger()
return x + 3;
}

int Function1(int x) { return x; }
int Function2(int x) { return x; }
int Function1(int x)
{
return x;
}
int Function2(int x)
{
return x;
}

int (*TestFunction(int x))(int)
{
Expand Down Expand Up @@ -80,11 +86,23 @@ Function *TestFunction2(int x)
class Foo
{
public:
int Operation1(int x) { return x; }
int Operation2(int x) { return x * 2; }
int Operation1(int x)
{
return x;
}
int Operation2(int x)
{
return x * 2;
}

int Method1() const { return 1; }
int Method2() const { return 2; }
int Method1() const
{
return 1;
}
int Method2() const
{
return 2;
}
};

int (Foo::*TestMember(int x))(int)
Expand Down Expand Up @@ -149,8 +167,14 @@ PtrConstMemberT TestConstMember2(int x)
return member;
}

int Function1() { return 1; }
int Function2() { return 2; }
int Function1()
{
return 1;
}
int Function2()
{
return 2;
}

struct Bar
{
Expand Down
File renamed without changes.
30 changes: 15 additions & 15 deletions results/diffs/EXF1.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..d4a9acc 100644
index e4fa731..4b3f11a 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -7,10 +7,16 @@ extern void TestExtractFunctionCFile();
@@ -6,10 +6,16 @@ extern void TestExtractFunctionCFile();

namespace ExtractFunction
{
+ void Goink(int& x)
+ {
+ x = 3;
+ }
+void goink(int &x)
+{
+ x = 3;
+}
+
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
- int x = 3;
+ int x;
+ Goink(x);
REQUIRE_EQUAL(3, x);
// #TEST#: EXF2 Extract function on statement
x *= 3;
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
- int x = 3;
+ int x;
+ goink(x);
REQUIRE_EQUAL(3, x);
// #TEST#: EXF2 Extract function on statement
x *= 3;
36 changes: 18 additions & 18 deletions results/diffs/EXF10.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..ef19526 100644
index e4fa731..8db307b 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -7,6 +7,11 @@ extern void TestExtractFunctionCFile();
@@ -6,6 +6,11 @@ extern void TestExtractFunctionCFile();

namespace ExtractFunction
{
+ void Goink(int& x)
+ {
+ x &= 3;
+ }
+void goink(int &x)
+{
+ x &= 3;
+}
+
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
@@ -38,7 +43,7 @@ namespace ExtractFunction
x |= 3;
REQUIRE_EQUAL(11, x);
// #TEST#: EXF10 Extract function on statement
- x &= 3;
+ Goink(x);
REQUIRE_EQUAL(3, x);
// #TEST#: EXF11 Extract function on expression
return x + 3;
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
@@ -37,7 +42,7 @@ int TestInteger()
x |= 3;
REQUIRE_EQUAL(11, x);
// #TEST#: EXF10 Extract function on statement
- x &= 3;
+ goink(x);
REQUIRE_EQUAL(3, x);
// #TEST#: EXF11 Extract function on expression
return x + 3;
34 changes: 17 additions & 17 deletions results/diffs/EXF11.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..39a76a7 100644
index e4fa731..fbe50c3 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -7,6 +7,11 @@ extern void TestExtractFunctionCFile();
@@ -6,6 +6,11 @@ extern void TestExtractFunctionCFile();

namespace ExtractFunction
{
+ int Goink(int x)
+ {
+ return x + 3;
+ }
+int goink(int x)
+{
+ return x + 3;
+}
+
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
@@ -41,7 +46,7 @@ namespace ExtractFunction
x &= 3;
REQUIRE_EQUAL(3, x);
// #TEST#: EXF11 Extract function on expression
- return x + 3;
+ return Goink(x);
}
int TestInteger()
{
// #TEST#: EXF1 Extract function on statement
@@ -40,7 +45,7 @@ int TestInteger()
x &= 3;
REQUIRE_EQUAL(3, x);
// #TEST#: EXF11 Extract function on expression
- return x + 3;
+ return goink(x);
}

int Function1(int x) { return x; }
int Function1(int x) { return x; }
36 changes: 18 additions & 18 deletions results/diffs/EXF12.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..7f619ac 100644
index 02dc2dd..2ec052d 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -47,13 +47,18 @@ namespace ExtractFunction
int Function1(int x) { return x; }
int Function2(int x) { return x; }
@@ -52,13 +52,18 @@ int Function2(int x)
return x;
}

+ void Goink(int(*& function)(int))
+ {
+ function = Function1;
+ }
+void goink(int (*&function)(int))
+{
+ function = Function1;
+}
+
int (*TestFunction(int x))(int)
int (*TestFunction(int x))(int)
{
int (*function)(int);
if (x > 0)
{
// #TEST#: EXF12 Extract function on statement
- function = Function1;
+ goink(function);
}
else
{
int (*function)(int);
if (x > 0)
{
// #TEST#: EXF12 Extract function on statement
- function = Function1;
+ Goink(function);
}
else
{
36 changes: 18 additions & 18 deletions results/diffs/EXF13.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..7b2fba7 100644
index 02dc2dd..53a5ecc 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -63,13 +63,19 @@ namespace ExtractFunction
}
@@ -68,13 +68,19 @@ int (*TestFunction(int x))(int)
}

typedef int Function(int);
typedef int Function(int);
+
+ void Goink(Function*& function)
+ {
+ function = Function1;
+ }
+void goink(Function *&function)
+{
+ function = Function1;
+}
+
Function *TestFunction2(int x)
Function *TestFunction2(int x)
{
Function *function;
if (x > 0)
{
// #TEST#: EXF13 Extract function on statement
- function = Function1;
+ goink(function);
}
else
{
Function *function;
if (x > 0)
{
// #TEST#: EXF13 Extract function on statement
- function = Function1;
+ Goink(function);
}
else
{
36 changes: 18 additions & 18 deletions results/diffs/EXF14.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..7c920e2 100644
index 02dc2dd..8d7fef1 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -88,13 +88,18 @@ namespace ExtractFunction
int Method2() const { return 2; }
};
@@ -105,13 +105,18 @@ public:
}
};

+ void Goink(int( Foo::*& member)(int))
+ {
+ member = &Foo::Operation1;
+ }
+void goink(int (Foo::*&member)(int))
+{
+ member = &Foo::Operation1;
+}
+
int (Foo::*TestMember(int x))(int)
int (Foo::*TestMember(int x))(int)
{
int (Foo::*member)(int);
if (x > 0)
{
// #TEST#: EXF14 Extract function on statement
- member = &Foo::Operation1;
+ goink(member);
}
else
{
int (Foo::*member)(int);
if (x > 0)
{
// #TEST#: EXF14 Extract function on statement
- member = &Foo::Operation1;
+ Goink(member);
}
else
{
36 changes: 18 additions & 18 deletions results/diffs/EXF15.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
diff --git a/RefactorTest/ExtractFunction.cpp b/RefactorTest/ExtractFunction.cpp
index d6416f3..2a5ccd8 100644
index 02dc2dd..bd99abd 100644
--- a/RefactorTest/ExtractFunction.cpp
+++ b/RefactorTest/ExtractFunction.cpp
@@ -104,13 +104,19 @@ namespace ExtractFunction
}
@@ -121,13 +121,19 @@ int (Foo::*TestMember(int x))(int)
}

typedef int (Foo::*PtrMemberT)(int);
typedef int (Foo::*PtrMemberT)(int);
+
+ void Goink(PtrMemberT& member)
+ {
+ member = &Foo::Operation1;
+ }
+void goink(PtrMemberT &member)
+{
+ member = &Foo::Operation1;
+}
+
PtrMemberT TestMember2(int x)
PtrMemberT TestMember2(int x)
{
PtrMemberT member;
if (x > 0)
{
// #TEST#: EXF15 Extract function on statement
- member = &Foo::Operation1;
+ goink(member);
}
else
{
PtrMemberT member;
if (x > 0)
{
// #TEST#: EXF15 Extract function on statement
- member = &Foo::Operation1;
+ Goink(member);
}
else
{
Loading

0 comments on commit 7571485

Please sign in to comment.