Commit 4b2d87a5 authored by Yushin Washio's avatar Yushin Washio
Browse files

What happens when a test fails? Introduce testcase...

What happens when a test fails? Introduce testcase T_Person_drone_hello_President assuming an unimplemented feature
parent f983a8cc
......@@ -4,9 +4,18 @@ using namespace std;
class Person
{
private:
string name;
public:
Person(string name) : name(name)
{
}
string hello()
{
return "Hi, how are you?";
}
string hello(Person other)
{
return "Hi " + other.name + ", how are you?";
}
};
......@@ -5,7 +5,8 @@ using namespace std;
int main (int argc, char *argv[])
{
Person drone;
cout << "Greeting drone..." << endl;
cout << "drone: " << drone.hello() << endl;
Person drone("drone");
Person electrobmw("electrobmw");
cout << "Drone greets electrobmw..." << endl;
cout << "drone: " << drone.hello(electrobmw) << endl;
}
......@@ -5,10 +5,34 @@
using namespace std;
void T_Person_drone_hello_none()
{
Person drone("drone");
assert(drone.hello() == "Hi, how are you?"); // T_Person_drone_hello_none
cout << "T_Person_drone_hello_none completed" << endl;
}
void T_Person_drone_hello_electrobmw()
{
Person drone("drone");
Person electrobmw("electrobmw");
assert(drone.hello(electrobmw) == "Hi electrobmw, how are you?"); // T_Person_drone_hello_electrobmw
cout << "T_Person_drone_hello_electrobmw completed" << endl;
}
void T_Person_drone_hello_President()
{
Person drone("drone");
Person president("Barack Obama");
// this will fail!
assert(drone.hello(president) == "His Excellency, how are you?"); // T_Person_drone_hello_President
cout << "T_Person_drone_hello_President completed" << endl;
}
int main (int argc, char *argv[])
{
Person drone;
assert(drone.hello() == "Hi, how are you?"); // Assert 001
cout << "drone: Assert 001 completed" << endl;
cout << "drone: All tests completed" << endl;
T_Person_drone_hello_none();
T_Person_drone_hello_electrobmw();
T_Person_drone_hello_President();
cout << "All tests completed" << endl;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment