THRIFT-5766 Replace std::endl with "\n"
Patch: Carel Combrink
This closes #2943
diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index 79a708e..a424620 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -155,7 +155,7 @@
loopEchoString();
break;
default:
- cerr << "Unexpected loop type" << _loopType << endl;
+ cerr << "Unexpected loop type" << _loopType << '\n';
break;
}
@@ -280,23 +280,23 @@
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
"[--clients=<client-count>] [--loop=<loop-count>] "
- "[--client-type=<client-type>]" << endl
+ "[--client-type=<client-type>]" << '\n'
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
- "server only. Default is " << clientCount << endl
- << "\thelp Prints this help text." << endl
- << "\tcall Service method to call. Default is " << callName << endl
- << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << endl
+ "server only. Default is " << clientCount << '\n'
+ << "\thelp Prints this help text." << '\n'
+ << "\tcall Service method to call. Default is " << callName << '\n'
+ << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n'
<< "\tport The port the server and clients should bind to "
- "for thrift network connections. Default is " << port << endl
- << "\tserver Run the Thrift server in this process. Default is " << runServer << endl
- << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << endl
- << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << endl
- << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << endl
- << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << endl
+ "for thrift network connections. Default is " << port << '\n'
+ << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n'
+ << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n'
+ << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n'
+ << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n'
+ << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n'
<< "\tworkers Number of thread pools workers. Only valid "
- "for thread-pool server type. Default is " << workerCount << endl
- << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << endl
- << endl;
+ "for thread-pool server type. Default is " << workerCount << '\n'
+ << "\tclient-type Type of client, \"regular\" or \"concurrent\". Default is " << clientType << '\n'
+ << '\n';
map<string, string> args;
@@ -386,7 +386,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cerr << usage.str();
}
@@ -468,7 +468,7 @@
server->setServerEventHandler(observer);
std::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
- cerr << "Starting the server on port " << port << endl;
+ cerr << "Starting the server on port " << port << '\n';
serverThread->start();
observer->waitForService();
@@ -538,7 +538,7 @@
Synchronized s(monitor);
threadCount = clientCount;
- cerr << "Launch " << clientCount << " " << clientType << " client threads" << endl;
+ cerr << "Launch " << clientCount << " " << clientType << " client threads" << '\n';
time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -591,14 +591,14 @@
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
- << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+ << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n';
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
- cerr << "done." << endl;
+ cerr << "done." << '\n';
}
return 0;
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index e94ecb2..d9d9ae6 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -152,7 +152,7 @@
loopEchoString();
break;
default:
- cerr << "Unexpected loop type" << _loopType << endl;
+ cerr << "Unexpected loop type" << _loopType << '\n';
break;
}
@@ -253,24 +253,20 @@
usage << argv[0] << " [--port=<port number>] [--server] [--server-type=<server-type>] "
"[--protocol-type=<protocol-type>] [--workers=<worker-count>] "
- "[--clients=<client-count>] [--loop=<loop-count>]" << endl
+ "[--clients=<client-count>] [--loop=<loop-count>]" << '\n'
<< "\tclients Number of client threads to create - 0 implies no clients, i.e. "
- "server only. Default is " << clientCount << endl
- << "\thelp Prints this help text." << endl
- << "\tcall Service method to call. Default is " << callName << endl
- << "\tloop The number of remote thrift calls each client makes. Default is "
- << loopCount << endl << "\tport The port the server and clients should bind to "
- "for thrift network connections. Default is " << port << endl
- << "\tserver Run the Thrift server in this process. Default is " << runServer
- << endl << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is "
- << serverType << endl
- << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is "
- << protocolType << endl
- << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests
- << endl << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is "
- << replayRequests << endl << "\tworkers Number of thread pools workers. Only valid "
- "for thread-pool server type. Default is " << workerCount
- << endl;
+ "server only. Default is " << clientCount << '\n'
+ << "\thelp Prints this help text." << '\n'
+ << "\tcall Service method to call. Default is " << callName << '\n'
+ << "\tloop The number of remote thrift calls each client makes. Default is " << loopCount << '\n'
+ << "\tport The port the server and clients should bind to for thrift network "
+ "connections. Default is " << port << '\n'
+ << "\tserver Run the Thrift server in this process. Default is " << runServer << '\n'
+ << "\tserver-type Type of server, \"simple\" or \"thread-pool\". Default is " << serverType << '\n'
+ << "\tprotocol-type Type of protocol, \"binary\", \"ascii\", or \"xml\". Default is " << protocolType << '\n'
+ << "\tlog-request Log all request to ./requestlog.tlog. Default is " << logRequests << '\n'
+ << "\treplay-request Replay requests from log file (./requestlog.tlog) Default is " << replayRequests << '\n'
+ << "\tworkers Number of thread pools workers. Only valid for thread-pool server type. Default is " << workerCount << '\n';
map<string, string> args;
@@ -338,7 +334,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cerr << usage.str();
}
@@ -416,7 +412,7 @@
new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager)));
}
- cerr << "Starting the server on port " << port << " and " << (port + 1) << endl;
+ cerr << "Starting the server on port " << port << " and " << (port + 1) << '\n';
serverThread->start();
serverThread2->start();
@@ -475,7 +471,7 @@
Synchronized s(monitor);
threadCount = clientCount;
- cerr << "Launch " << clientCount << " client threads" << endl;
+ cerr << "Launch " << clientCount << " client threads" << '\n';
time00 = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
@@ -528,14 +524,14 @@
averageTime /= clientCount;
cout << "workers :" << workerCount << ", client : " << clientCount << ", loops : " << loopCount
- << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << endl;
+ << ", rate : " << (clientCount * loopCount * 1000) / ((double)(time01 - time00)) << '\n';
count_map count = serviceHandler->getCount();
count_map::iterator iter;
for (iter = count.begin(); iter != count.end(); ++iter) {
printf("%s => %d\n", iter->first, iter->second);
}
- cerr << "done." << endl;
+ cerr << "done." << '\n';
}
return 0;
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;
}
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 6c61f40..afd2938 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -394,7 +394,7 @@
}
void communicate(const char* event, void* ctx, const char* fn_name) {
- std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << std::endl;
+ std::cout << event << ": " << *static_cast<std::string*>(ctx) << " = " << fn_name << '\n';
}
};
@@ -655,7 +655,7 @@
}
} catch (std::exception& e) {
- cerr << e.what() << endl;
+ cerr << e.what() << '\n';
cout << desc << "\n";
return 1;
}
@@ -767,7 +767,7 @@
if (port != 0) {
cout << port;
}
- cout << endl;
+ cout << '\n';
// Multiplexed Processor if needed
if (boost::starts_with(protocol_type, "multi")) {
@@ -823,7 +823,7 @@
: new transport::TNonblockingServerSocket(port));
server.reset(new TNonblockingServer(testProcessor, protocolFactory, nbSocket));
} else {
- cerr << "server-type nonblocking requires transport of http or framed" << endl;
+ cerr << "server-type nonblocking requires transport of http or framed" << '\n';
exit(1);
}
}
@@ -857,6 +857,6 @@
server.reset();
}
- cout << "done." << endl;
+ cout << "done." << '\n';
return 0;
}