Special-case greetings with an empty greetee.
This fixes a bug where with an empty greetee you would get an extra
space between “hello” and the exclamation mark.
Change-Id: Ifea66e4ac465fdf1ca94e754296d6ef469e062ec
diff --git a/mod/greeting.cpp b/mod/greeting.cpp
index a8101b8..62ebb2d 100644
--- a/mod/greeting.cpp
+++ b/mod/greeting.cpp
@@ -5,9 +5,13 @@
namespace greeting {
std::string make_greeting(std::string const& greetee) {
- std::ostringstream out;
- out << "Hello " << greetee << "!";
- return out.str();
+ if (greetee == "") {
+ return "Hello!";
+ } else {
+ std::ostringstream out;
+ out << "Hello " << greetee << "!";
+ return out.str();
+ }
}
}