-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixme_hello_main.cpp
More file actions
87 lines (82 loc) · 2.19 KB
/
fixme_hello_main.cpp
File metadata and controls
87 lines (82 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
6 kyu
FIXME: Hello
https://www.codewars.com/kata/5b0a80ce84a30f4762000069
*/
#include <iostream>
#include <string>
class Dinglemouse {
std::string name;
int age;
char sex;
std::string msg;
public:
Dinglemouse();
Dinglemouse& setAge(int age);
Dinglemouse& setSex(char sex);
Dinglemouse& setName(const std::string& name);
std::string hello();
};
static void doTest(const std::string& expected, const std::string& actual) {
std::cout << "Expected string; \"" << expected << "\"" << std::endl
<< "Actual string : \"" << actual << "\"" << std::endl
<< "-> " << (expected == actual ? "OK" : "FAIL") << std::endl
<< std::endl;
}
int main() {
{
Dinglemouse dm;
std::string expected = "Hello.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setName("Bob").setAge(27).setSex('M');
std::string expected = "Hello. My name is Bob. I am 27. I am male.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setAge(27).setSex('M').setName("Bob");
std::string expected = "Hello. I am 27. I am male. My name is Bob.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setName("Alice").setSex('M').setSex('F');
std::string expected = "Hello. My name is Alice. I am female.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setName("Batman").setName("Catwoman");
std::string expected = "Hello. My name is Catwoman.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setName("Batman");
std::string expected = "Hello. My name is Batman.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setAge(27).setAge(28).setAge(29);
std::string expected = "Hello. I am 29.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setSex('F').setSex('M').setAge(27).setAge(52).setName("Rick").setName(
"Dick");
std::string expected = "Hello. I am male. I am 52. My name is Dick.";
doTest(expected, dm.hello());
}
{
Dinglemouse dm;
dm.setAge(52).setSex('F').setName("Dick").setSex('M');
std::string expected = "Hello. I am 52. I am male. My name is Dick.";
doTest(expected, dm.hello());
}
return 0;
}