Skip to content

Commit

Permalink
Add dynamic polymorphism Add Parameter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Dec 30, 2023
1 parent 0770422 commit 35046a6
Show file tree
Hide file tree
Showing 26 changed files with 1,719 additions and 24 deletions.
117 changes: 117 additions & 0 deletions RefactorTest/AddParameter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include "AddParameter.h"
#include "Require.h"

// Adds a new parameter to a method declaration and updates all calls accordingly.

namespace
{

void f1();

} // namespace

// #TEST#: AP149 Add parameter, int goink
static AddParameterTester *GetOne();

Expand Down Expand Up @@ -148,6 +156,8 @@ void TestAddParameter()
// #TEST#: AP139 Add parameter, int goink
def3 = GetOne();
delete def3;

f1();
}

// #TEST#: AP140 Add parameter, int goink
Expand Down Expand Up @@ -239,3 +249,110 @@ void AddParameterStruct::Static()
void AddParameterStruct::StaticDefault(int x, int y)
{
}

namespace
{

class Interface
{
public:
virtual ~Interface()
{
}

// #TEST#: AP150 Add parameter, int goink
virtual int fn() = 0;

// #TEST#: AP151 Add parameter, int goink
virtual int fn2(int x) = 0;
};

class Derived : public Interface
{
public:
~Derived() override = default;

// #TEST#: AP152 Add parameter, int goink
int fn() override;

// #TEST#: AP153 Add parameter, int goink
int fn2(int x) override;
};

class OtherDerived : public Interface
{
public:
~OtherDerived() override = default;

// #TEST#: AP154 Add parameter, int goink
int fn() override
{
return 3;
}

// #TEST#: AP155 Add parameter, int goink
int fn2(int x) override
{
return x + 2;
}
};

class MoreDerived : public Derived
{
public:
~MoreDerived() override = default;

// #TEST#: AP156 Add parameter, int goink
int fn() override;

// #TEST#: AP157 Add parameter, int goink
int fn2(int x) override;
};

// #TEST#: AP158 Add parameter, int goink
int Derived::fn()
{
return 1;
}

// #TEST#: AP159 Add parameter, int goink
int Derived::fn2(int x)
{
return x;
}

// #TEST#: AP160 Add parameter, int goink
int MoreDerived::fn()
{
return 2;
}

// #TEST#: AP161 Add parameter, int goink
int MoreDerived::fn2(int x)
{
// #TEST#: AP162 Add parameter, int goink
return 1 + Derived::fn2(x);
}

void f1()
{
Derived d;
// #TEST#: AP163 Add parameter, int goink
REQUIRE_EQUAL(1, d.fn());
// #TEST#: AP164 Add parameter, int goink
REQUIRE_EQUAL(2, d.fn2(2));

MoreDerived md;
// #TEST#: AP165 Add parameter, int goink
REQUIRE_EQUAL(2, md.fn());
// #TEST#: AP166 Add parameter, int goink
REQUIRE_EQUAL(3, md.fn2(2));

OtherDerived od;
// #TEST#: AP167 Add parameter, int goink
REQUIRE_EQUAL(3, od.fn());
// #TEST#: AP168 Add parameter, int goink
REQUIRE_EQUAL(4, od.fn2(2));
}

} // namespace
10 changes: 6 additions & 4 deletions results/diffs/AP139.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index a759b33..c1b0071 100644
index 44d4092..4c55253 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -3,7 +3,7 @@
// Adds a new parameter to a method declaration and updates all calls accordingly.
@@ -11,7 +11,7 @@ void f1();
} // namespace

// #TEST#: AP149 Add parameter, int goink
-static AddParameterTester *GetOne();
+static AddParameterTester *GetOne(int goink);

class AddParameterTester2
{
@@ -146,12 +146,12 @@ void TestAddParameter()
@@ -154,14 +154,14 @@ void TestAddParameter()
def3 = new AddParameterTester();
delete def3;
// #TEST#: AP139 Add parameter, int goink
- def3 = GetOne();
+ def3 = GetOne(0);
delete def3;

f1();
}

// #TEST#: AP140 Add parameter, int goink
Expand Down
10 changes: 6 additions & 4 deletions results/diffs/AP140.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index a759b33..c1b0071 100644
index 44d4092..4c55253 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -3,7 +3,7 @@
// Adds a new parameter to a method declaration and updates all calls accordingly.
@@ -11,7 +11,7 @@ void f1();
} // namespace

// #TEST#: AP149 Add parameter, int goink
-static AddParameterTester *GetOne();
+static AddParameterTester *GetOne(int goink);

class AddParameterTester2
{
@@ -146,12 +146,12 @@ void TestAddParameter()
@@ -154,14 +154,14 @@ void TestAddParameter()
def3 = new AddParameterTester();
delete def3;
// #TEST#: AP139 Add parameter, int goink
- def3 = GetOne();
+ def3 = GetOne(0);
delete def3;

f1();
}

// #TEST#: AP140 Add parameter, int goink
Expand Down
10 changes: 5 additions & 5 deletions results/diffs/AP141.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index a759b33..13a2332 100644
index 44d4092..0c87e99 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -42,7 +42,7 @@ void TestAddParameter()
@@ -50,7 +50,7 @@ void TestAddParameter()
// #TEST#: AP92 Add parameter before first, int goink
AddParameterFnDefault(1);

Expand All @@ -11,7 +11,7 @@ index a759b33..13a2332 100644
// #TEST#: AP93 Add parameter, int *goink
test.AddParameter();
// #TEST#: AP94 Add parameter, int goink
@@ -137,13 +137,13 @@ void TestAddParameter()
@@ -145,13 +145,13 @@ void TestAddParameter()
inner2.Operation();

// default constructor
Expand All @@ -29,7 +29,7 @@ index a759b33..13a2332 100644
delete def3;
// #TEST#: AP139 Add parameter, int goink
def3 = GetOne();
@@ -154,7 +154,7 @@ void TestAddParameter()
@@ -164,7 +164,7 @@ void TestAddParameter()
static AddParameterTester *GetOne()
{
// #TEST#: AP141 Add parameter, int goink
Expand All @@ -39,7 +39,7 @@ index a759b33..13a2332 100644

// #TEST#: AP13 Add parameter, int *goink
diff --git a/RefactorTest/AddParameter.h b/RefactorTest/AddParameter.h
index fa2ecc5..716a5b2 100644
index 7e94f5d..ef56d57 100644
--- a/RefactorTest/AddParameter.h
+++ b/RefactorTest/AddParameter.h
@@ -17,7 +17,7 @@ class AddParameterTester
Expand Down
9 changes: 5 additions & 4 deletions results/diffs/AP147.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index a759b33..0458253 100644
index 44d4092..4057a7e 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -106,10 +106,10 @@ void TestAddParameter()
@@ -114,10 +114,10 @@ void TestAddParameter()
AddParameterStruct::Static();
// #TEST#: AP124 Add parameter before y, int goink
// #TEST#: AP125 Add parameter after y, int goink = 3
Expand All @@ -15,16 +15,17 @@ index a759b33..0458253 100644
// #TEST#: AP128 Add parameter, int goink
AddParameterStruct::StaticTemplate<int>(0);
// #TEST#: AP129 Add parameter before x, int goink
@@ -236,6 +236,6 @@ void AddParameterStruct::Static()
@@ -246,7 +246,7 @@ void AddParameterStruct::Static()

// #TEST#: AP147 Add parameter before y, int goink
// #TEST#: AP148 Add parameter after y, int goink = 3
-void AddParameterStruct::StaticDefault(int x, int y)
+void AddParameterStruct::StaticDefault(int x, int goink, int y)
{
}

diff --git a/RefactorTest/AddParameter.h b/RefactorTest/AddParameter.h
index fa2ecc5..84bec5a 100644
index 7e94f5d..329cbe6 100644
--- a/RefactorTest/AddParameter.h
+++ b/RefactorTest/AddParameter.h
@@ -149,7 +149,7 @@ struct AddParameterStruct
Expand Down
7 changes: 4 additions & 3 deletions results/diffs/AP148.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index a759b33..e013706 100644
index 44d4092..1e33555 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -236,6 +236,6 @@ void AddParameterStruct::Static()
@@ -246,7 +246,7 @@ void AddParameterStruct::Static()

// #TEST#: AP147 Add parameter before y, int goink
// #TEST#: AP148 Add parameter after y, int goink = 3
-void AddParameterStruct::StaticDefault(int x, int y)
+void AddParameterStruct::StaticDefault(int x, int y, int goink)
{
}

diff --git a/RefactorTest/AddParameter.h b/RefactorTest/AddParameter.h
index fa2ecc5..7d55a84 100644
index 7e94f5d..3929af9 100644
--- a/RefactorTest/AddParameter.h
+++ b/RefactorTest/AddParameter.h
@@ -149,7 +149,7 @@ struct AddParameterStruct
Expand Down
10 changes: 6 additions & 4 deletions results/diffs/AP149.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index 0d89cb2..c7dce3c 100644
index 44d4092..4c55253 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -3,7 +3,7 @@
// Adds a new parameter to a method declaration and updates all calls accordingly.
@@ -11,7 +11,7 @@ void f1();
} // namespace

// #TEST#: AP149 Add parameter, int goink
-static AddParameterTester *GetOne();
+static AddParameterTester *GetOne(int goink);

class AddParameterTester2
{
@@ -146,12 +146,12 @@ void TestAddParameter()
@@ -154,14 +154,14 @@ void TestAddParameter()
def3 = new AddParameterTester();
delete def3;
// #TEST#: AP139 Add parameter, int goink
- def3 = GetOne();
+ def3 = GetOne(0);
delete def3;

f1();
}

// #TEST#: AP140 Add parameter, int goink
Expand Down
80 changes: 80 additions & 0 deletions results/diffs/AP150.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
diff --git a/RefactorTest/AddParameter.cpp b/RefactorTest/AddParameter.cpp
index 2214789..a1f94f6 100644
--- a/RefactorTest/AddParameter.cpp
+++ b/RefactorTest/AddParameter.cpp
@@ -261,7 +261,7 @@ public:
}

// #TEST#: AP150 Add parameter, int goink
- virtual int fn() = 0;
+ virtual int fn(int goink) = 0;

// #TEST#: AP151 Add parameter, int goink
virtual int fn2(int x) = 0;
@@ -273,7 +273,7 @@ public:
~Derived() override = default;

// #TEST#: AP152 Add parameter, int goink
- int fn() override;
+ int fn(int goink) override;

// #TEST#: AP153 Add parameter, int goink
int fn2(int x) override;
@@ -285,7 +285,7 @@ public:
~OtherDerived() override = default;

// #TEST#: AP154 Add parameter, int goink
- int fn() override
+ int fn(int goink) override
{
return 3;
}
@@ -303,14 +303,14 @@ public:
~MoreDerived() override = default;

// #TEST#: AP156 Add parameter, int goink
- int fn() override;
+ int fn(int goink) override;

// #TEST#: AP157 Add parameter, int goink
int fn2(int x) override;
};

// #TEST#: AP158 Add parameter, int goink
-int Derived::fn()
+int Derived::fn(int goink)
{
return 1;
}
@@ -322,7 +322,7 @@ int Derived::fn2(int x)
}

// #TEST#: AP160 Add parameter, int goink
-int MoreDerived::fn()
+int MoreDerived::fn(int goink)
{
return 2;
}
@@ -338,19 +338,19 @@ void f1()
{
Derived d;
// #TEST#: AP163 Add parameter, int goink
- REQUIRE_EQUAL(1, d.fn());
+ REQUIRE_EQUAL(1, d.fn(0));
// #TEST#: AP164 Add parameter, int goink
REQUIRE_EQUAL(2, d.fn2(2));

MoreDerived md;
// #TEST#: AP165 Add parameter, int goink
- REQUIRE_EQUAL(2, md.fn());
+ REQUIRE_EQUAL(2, md.fn(0));
// #TEST#: AP166 Add parameter, int goink
REQUIRE_EQUAL(3, md.fn2(2));

OtherDerived od;
// #TEST#: AP167 Add parameter, int goink
- REQUIRE_EQUAL(3, od.fn());
+ REQUIRE_EQUAL(3, od.fn(0));
// #TEST#: AP168 Add parameter, int goink
REQUIRE_EQUAL(4, od.fn2(2));
}
Loading

0 comments on commit 35046a6

Please sign in to comment.