diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index fd04ed8..c15281a 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -98,7 +98,7 @@
                 ss << "ERROR: send request with seqid " << m_last_seqid << " and got reply with seqid " << seqid;
                 throw std::logic_error(ss.str());
             } /* else {
-                std::cout << "verified seqid " << m_last_seqid << " round trip OK" << std::endl;
+                std::cout << "verified seqid " << m_last_seqid << " round trip OK" << '\n';
             } */
             return result;
         }
@@ -127,9 +127,9 @@
     std::ostringstream os;
     os << "test" << testNr;
     const bool ok = (s == os.str());
-    cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << endl;
+    cout << "testString: " << s << " " << ((ok) ? "ok" : "failed") << '\n';
   } catch (TException& exn) {
-    cout << "Error: " << exn.what() << endl;
+    cout << "Error: " << exn.what() << '\n';
   }
 
   if (testNr == 9)
@@ -139,7 +139,7 @@
 static void testVoid_clientReturn(event_base* base, ThriftTestCobClient* client) {
   try {
     client->recv_testVoid();
-    cout << "testVoid" << endl;
+    cout << "testVoid" << '\n';
 
     for (int testNr = 0; testNr < 10; ++testNr) {
       std::ostringstream os;
@@ -151,16 +151,16 @@
                        os.str());
     }
   } catch (TException& exn) {
-    cout << "Error: " << exn.what() << endl;
+    cout << "Error: " << exn.what() << '\n';
   }
 }
 
 // Workaround for absense of C++11 "auto" keyword.
 template <typename T>
 bool print_eq(T expected, T actual) {
-  cout << "(" << actual << ")" << endl;
+  cout << "(" << actual << ")" << '\n';
   if (expected != actual) {
-    cout << "*** FAILED ***" << endl << "Expected: " << expected << " but got: " << actual << endl;
+    cout << "*** FAILED ***" << '\n' << "Expected: " << expected << " but got: " << actual << '\n';
     return false;
   }
   return true;
@@ -174,7 +174,7 @@
   } catch (TTransportException&) {                                                                 \
     throw;                                                                                         \
   } catch (exception & ex) {                                                                       \
-    cout << "*** FAILED ***" << endl << ex.what() << endl;                                         \
+    cout << "*** FAILED ***" << '\n' << ex.what() << '\n';                                         \
     return_code |= ERR_BASETYPES;                                                                  \
   }
 
@@ -186,7 +186,7 @@
   } catch (TTransportException&) {                                                                 \
     throw;                                                                                         \
   } catch (exception & ex) {                                                                       \
-    cout << "*** FAILED ***" << endl << ex.what() << endl;                                         \
+    cout << "*** FAILED ***" << '\n' << ex.what() << '\n';                                         \
     return_code |= ERR_BASETYPES;                                                                  \
   }
 
@@ -258,7 +258,7 @@
   boost::program_options::notify(vm);
 
   if (vm.count("help")) {
-    cout << desc << endl;
+    cout << desc << '\n';
     return ERR_UNKNOWN;
   }
 
@@ -290,8 +290,8 @@
     }
 
   } catch (exception& e) {
-    cerr << e.what() << endl;
-    cout << desc << endl;
+    cerr << e.what() << '\n';
+    cout << desc << '\n';
     return ERR_UNKNOWN;
   }
 
@@ -319,9 +319,9 @@
   std::shared_ptr<TProtocol> protocol2;  // SecondService for multiplexed
 
   if (ssl) {
-    cout << "Client Certificate File: " << certPath << endl;
-    cout << "Client Key         File: " << keyPath << endl;
-    cout << "CA                 File: " << caPath << endl;
+    cout << "Client Certificate File: " << certPath << '\n';
+    cout << "Client Key         File: " << keyPath << '\n';
+    cout << "CA                 File: " << caPath << '\n';
 
     factory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
     factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
@@ -386,14 +386,14 @@
   if (port != 0) {
     cout << host << ":" << port;
   }
-  cout << endl;
+  cout << '\n';
 
   if (transport_type.compare("evhttp") == 0) {
     event_base* base = event_base_new();
-    cout << "Libevent Version: " << event_get_version() << endl;
-    cout << "Libevent Method: " << event_base_get_method(base) << endl;
+    cout << "Libevent Version: " << event_get_version() << '\n';
+    cout << "Libevent Method: " << event_base_get_method(base) << '\n';
 #if LIBEVENT_VERSION_NUMBER >= 0x02000000
-    cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl;
+    cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << '\n';
 #endif
 
     std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
@@ -421,7 +421,7 @@
     try {
       transport->open();
     } catch (TTransportException& ex) {
-      cout << "Connect failed: " << ex.what() << endl;
+      cout << "Connect failed: " << ex.what() << '\n';
       return ERR_UNKNOWN;
     }
 
@@ -438,12 +438,12 @@
     try {
       cout << "testVoid()" << flush;
       testClient.testVoid();
-      cout << " = void" << endl;
+      cout << " = void" << '\n';
     } catch (TTransportException&) {
       // Stop here if transport got broken
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_BASETYPES;
     }
 
@@ -453,9 +453,9 @@
     cout << "testString(\"Test\")" << flush;
     string s;
     testClient.testString(s, "Test");
-    cout << " = " << s << endl;
+    cout << " = " << s << '\n';
     if (s != "Test") {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_BASETYPES;
     }
 
@@ -471,9 +471,9 @@
           cout << "secondService.secondTestString(\"foo\") => " << flush;
         std::string result;
       ssc.secondtestString(result, "foo");
-      cout << "{" << result << "}" << endl;
+      cout << "{" << result << "}" << '\n';
       } catch (std::exception& e) {
-      cout << "  *** FAILED *** " << e.what() << endl;
+      cout << "  *** FAILED *** " << e.what() << '\n';
       return_code |= ERR_EXCEPTIONS;
     }
     }
@@ -514,16 +514,16 @@
 #endif
       cout << "testString(" << str << ") = " << flush;
       testClient.testString(s, str);
-      cout << s << endl;
+      cout << s << '\n';
       if (s != str) {
         cout.imbue(locale("en_US.UTF8"));
-        cout << "*** FAILED ***" << endl << "Expected string: " << str << " but got: " << s << endl << "CLEAR";
+        cout << "*** FAILED ***" << '\n' << "Expected string: " << str << " but got: " << s << '\n' << "CLEAR";
         return_code |= ERR_BASETYPES;
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_BASETYPES;
       return return_code;
     }
@@ -537,11 +537,11 @@
           " char-to-test-json-parsing: ]] \"]] \\\" }}}{ [[[ ");
       cout << "testString(" << str << ") = " << flush;
       testClient.testString(s, str);
-      cout << s << endl;
+      cout << s << '\n';
       if (s != str) {
         cout.imbue(locale("en_US.UTF8"));
-        cout << "*** FAILED ***" << endl
-             << "Expected string: " << str << " but got: " << s << endl
+        cout << "*** FAILED ***" << '\n'
+             << "Expected string: " << str << " but got: " << s << '\n'
              << "CLEAR";
         ;
         return_code |= ERR_BASETYPES;
@@ -549,7 +549,7 @@
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_BASETYPES;
       return return_code;
     }
@@ -614,15 +614,15 @@
       double expected = pow(static_cast<double>(10), 307);
       cout << "testDouble(" << expected << ") = " << flush;
       double actual = testClient.testDouble(expected);
-      cout << "(" << actual << ")" << endl;
+      cout << "(" << actual << ")" << '\n';
       if (expected - actual > pow(static_cast<double>(10), 292)) {
-        cout << "*** FAILED ***" << endl
-             << "Expected: " << expected << " but got: " << actual << endl;
+        cout << "*** FAILED ***" << '\n'
+             << "Expected: " << expected << " but got: " << actual << '\n';
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_BASETYPES;
     }
 
@@ -630,15 +630,15 @@
       double expected = pow(static_cast<double>(10), -292);
       cout << "testDouble(" << expected << ") = " << flush;
       double actual = testClient.testDouble(expected);
-      cout << "(" << actual << ")" << endl;
+      cout << "(" << actual << ")" << '\n';
       if (expected - actual > pow(static_cast<double>(10), -307)) {
-        cout << "*** FAILED ***" << endl
-             << "Expected: " << expected << " but got: " << actual << endl;
+        cout << "*** FAILED ***" << '\n'
+             << "Expected: " << expected << " but got: " << actual << '\n';
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_BASETYPES;
     }
 
@@ -677,7 +677,7 @@
            in.i32_thing,
            in.i64_thing);
     if (in != out) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
@@ -700,7 +700,7 @@
            in.i64_thing,
            in2.i32_thing);
     if (in2 != out2) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
@@ -735,9 +735,9 @@
       }
       cout << m_iter->first << " => " << m_iter->second;
     }
-    cout << "}" << endl;
+    cout << "}" << '\n';
     if (mapin != mapout) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_CONTAINERS;
     }
 
@@ -760,15 +760,15 @@
           first = false;
         cout << it->first << " => " << it->second;
       }
-      cout << "}" << endl;
+      cout << "}" << '\n';
       if (smapin != smapout) {
-        cout << "*** FAILED ***" << endl;
+        cout << "*** FAILED ***" << '\n';
         return_code |= ERR_CONTAINERS;
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_CONTAINERS;
     }
 
@@ -803,9 +803,9 @@
       }
       cout << *s_iter;
     }
-    cout << "}" << endl;
+    cout << "}" << '\n';
     if (setin != setout) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_CONTAINERS;
     }
 
@@ -817,14 +817,14 @@
       vector<int32_t> listout;
       testClient.testList(listout, vector<int32_t>());
       if (!listout.empty()) {
-        cout << "*** FAILED ***" << endl;
-        cout << "invalid length: " << listout.size() << endl;
+        cout << "*** FAILED ***" << '\n';
+        cout << "invalid length: " << listout.size() << '\n';
         return_code |= ERR_CONTAINERS;
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_CONTAINERS;
     }
     try {
@@ -856,15 +856,15 @@
         }
         cout << *l_iter;
       }
-      cout << "}" << endl;
+      cout << "}" << '\n';
       if (listin != listout) {
-        cout << "*** FAILED ***" << endl;
+        cout << "*** FAILED ***" << '\n';
         return_code |= ERR_CONTAINERS;
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_CONTAINERS;
     }
 
@@ -873,41 +873,41 @@
      */
     cout << "testEnum(ONE)" << flush;
     Numberz::type ret = testClient.testEnum(Numberz::ONE);
-    cout << " = " << ret << endl;
+    cout << " = " << ret << '\n';
     if (ret != Numberz::ONE) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
     cout << "testEnum(TWO)" << flush;
     ret = testClient.testEnum(Numberz::TWO);
-    cout << " = " << ret << endl;
+    cout << " = " << ret << '\n';
     if (ret != Numberz::TWO) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
     cout << "testEnum(THREE)" << flush;
     ret = testClient.testEnum(Numberz::THREE);
-    cout << " = " << ret << endl;
+    cout << " = " << ret << '\n';
     if (ret != Numberz::THREE) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
     cout << "testEnum(FIVE)" << flush;
     ret = testClient.testEnum(Numberz::FIVE);
-    cout << " = " << ret << endl;
+    cout << " = " << ret << '\n';
     if (ret != Numberz::FIVE) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
     cout << "testEnum(EIGHT)" << flush;
     ret = testClient.testEnum(Numberz::EIGHT);
-    cout << " = " << ret << endl;
+    cout << " = " << ret << '\n';
     if (ret != Numberz::EIGHT) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
@@ -916,9 +916,9 @@
      */
     cout << "testTypedef(309858235082523)" << flush;
     UserId uid = testClient.testTypedef(309858235082523LL);
-    cout << " = " << uid << endl;
+    cout << " = " << uid << '\n';
     if (uid != 309858235082523LL) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_STRUCTS;
     }
 
@@ -938,7 +938,7 @@
       }
       cout << "}, ";
     }
-    cout << "}" << endl;
+    cout << "}" << '\n';
     if (mm.size() != 2 ||
         mm[-4][-4] != -4 ||
         mm[-4][-3] != -3 ||
@@ -948,7 +948,7 @@
         mm[4][3] != 3 ||
         mm[4][2] != 2 ||
         mm[4][1] != 1) {
-      cout << "*** FAILED ***" << endl;
+      cout << "*** FAILED ***" << '\n';
       return_code |= ERR_CONTAINERS;
     }
 
@@ -1005,7 +1005,7 @@
         }
         cout << "}, ";
       }
-      cout << "}" << endl;
+      cout << "}" << '\n';
       bool failed = false;
       map<UserId, map<Numberz::type, Insanity> >::const_iterator it1 = whoa.find(UserId(1));
       if (whoa.size() != 2) {
@@ -1033,7 +1033,7 @@
         }
       }
       if (failed) {
-        cout << "*** FAILED ***" << endl;
+        cout << "*** FAILED ***" << '\n';
         return_code |= ERR_STRUCTS;
       }
     }
@@ -1041,7 +1041,7 @@
     /**
      * MULTI TEST
      */
-    cout << "testMulti()" << endl;
+    cout << "testMulti()" << '\n';
     try {
       map<int16_t, string> mul_map;
       Xtruct mul_result;
@@ -1054,13 +1054,13 @@
       xxs.i32_thing = 4242;
       xxs.i64_thing = 424242;
       if (mul_result != xxs) {
-        cout << "*** FAILED ***" << endl;
+        cout << "*** FAILED ***" << '\n';
         return_code |= ERR_STRUCTS;
       }
     } catch (TTransportException&) {
       throw;
     } catch (exception& ex) {
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_STRUCTS;
     }
 
@@ -1069,7 +1069,7 @@
     try {
       cout << "testClient.testException(\"Xception\") =>" << flush;
       testClient.testException("Xception");
-      cout << "  void\n*** FAILED ***" << endl;
+      cout << "  void\n*** FAILED ***" << '\n';
       return_code |= ERR_EXCEPTIONS;
 
     } catch (Xception& e) {
@@ -1079,19 +1079,19 @@
     try {
       cout << "testClient.testException(\"TException\") =>" << flush;
       testClient.testException("TException");
-      cout << "  void\n*** FAILED ***" << endl;
+      cout << "  void\n*** FAILED ***" << '\n';
       return_code |= ERR_EXCEPTIONS;
 
     } catch (const TException&) {
-      cout << "  Caught TException" << endl;
+      cout << "  Caught TException" << '\n';
     }
 
     try {
       cout << "testClient.testException(\"success\") =>" << flush;
       testClient.testException("success");
-      cout << "  void" << endl;
+      cout << "  void" << '\n';
     } catch (exception & ex) {                                                                       \
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_EXCEPTIONS;
     }
 
@@ -1101,7 +1101,7 @@
       cout << "testClient.testMultiException(\"Xception\", \"test 1\") =>" << flush;
       Xtruct result;
       testClient.testMultiException(result, "Xception", "test 1");
-      cout << "  result\n*** FAILED ***" << endl;
+      cout << "  result\n*** FAILED ***" << '\n';
       return_code |= ERR_EXCEPTIONS;
     } catch (Xception& e) {
       printf("  {%u, \"%s\"}\n", e.errorCode, e.message.c_str());
@@ -1111,7 +1111,7 @@
       cout << "testClient.testMultiException(\"Xception2\", \"test 2\") =>" << flush;
       Xtruct result;
       testClient.testMultiException(result, "Xception2", "test 2");
-      cout << "  result\n*** FAILED ***" << endl;
+      cout << "  result\n*** FAILED ***" << '\n';
       return_code |= ERR_EXCEPTIONS;
 
     } catch (Xception2& e) {
@@ -1124,7 +1124,7 @@
       testClient.testMultiException(result, "success", "test 3");
       printf("  {{\"%s\"}}\n", result.string_thing.c_str());
     } catch (exception & ex) {                                                                       \
-      cout << "*** FAILED ***" << endl << ex.what() << endl;
+      cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
       return_code |= ERR_EXCEPTIONS;
     }
 
@@ -1155,16 +1155,16 @@
      */
     cout << "re-test testI32(-1)" << flush;
     int i32 = testClient.testI32(-1);
-    cout << " = " << i32 << endl;
+    cout << " = " << i32 << '\n';
     if (i32 != -1)
       return_code |= ERR_BASETYPES;
 
-    cout << endl << "All tests done." << endl << flush;
+    cout << '\n' << "All tests done." << '\n' << flush;
 
     uint64_t stop = now();
     uint64_t tot = stop - start;
 
-    cout << "Total time: " << stop - start << " us" << endl;
+    cout << "Total time: " << stop - start << " us" << '\n';
 
     time_tot += tot;
     if (time_min == 0 || tot < time_min) {
@@ -1181,9 +1181,9 @@
 
   uint64_t time_avg = time_tot / numTests;
 
-  cout << "Min time: " << time_min << " us" << endl;
-  cout << "Max time: " << time_max << " us" << endl;
-  cout << "Avg time: " << time_avg << " us" << endl;
+  cout << "Min time: " << time_min << " us" << '\n';
+  cout << "Max time: " << time_max << " us" << '\n';
+  cout << "Avg time: " << time_avg << " us" << '\n';
 
   return return_code;
 }
@@ -1225,26 +1225,26 @@
     string bin_request;
     string bin_result;
 
-    cout << "testBinary(siz = " << siz << ")" << endl;
+    cout << "testBinary(siz = " << siz << ")" << '\n';
     binary_fill(bin_request, siz);
     try {
         testClient.testBinary(bin_result, bin_request);
 
         if (bin_request.size() != bin_result.size()) {
-            cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << endl;
+            cout << "*** FAILED: request size " << bin_request.size() << "; result size " << bin_result.size() << '\n';
             return ERR_BASETYPES;
         }
 
         for (string::size_type i = 0; i < siz; ++i) {
             if (bin_request.at(i) != bin_result.at(i)) {
-                cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << endl;
+                cout << "*** FAILED: at position " << i << " request[i] is h" << hex << bin_request.at(i) << " result[i] is h" << hex << bin_result.at(i) << '\n';
                 return ERR_BASETYPES;
             }
         }
     } catch (TTransportException&) {
         throw;
     } catch (exception& ex) {
-        cout << "*** FAILED ***" << endl << ex.what() << endl;
+        cout << "*** FAILED ***" << '\n' << ex.what() << '\n';
         return ERR_BASETYPES;
     }
 
