fix unittest warnings + remove trailing spaces

This commit is contained in:
Benjamin Sergeant
2019-09-12 11:43:52 -07:00
parent a55d4cdb76
commit 57086e28d8
25 changed files with 87 additions and 106 deletions

View File

@ -135,12 +135,12 @@ namespace
if (!msg.isMember("user")) return;
if (!msg.isMember("text")) return;
if (!msg.isMember("session")) return;
std::string msg_user = msg["user"].asString();
std::string msg_text = msg["text"].asString();
std::string msg_session = msg["session"].asString();
// We are not interested in messages
// We are not interested in messages
// from a different session.
if (msg_session != _session) return;
@ -150,7 +150,7 @@ namespace
_receivedQueue.push(msg);
std::stringstream ss;
ss << std::endl
ss << std::endl
<< msg_user << " > " << msg_text
<< std::endl
<< _user << " > ";
@ -246,7 +246,7 @@ namespace
std::stringstream ss;
ss << "Sending msg [" << text << "]";
log(ss.str());
Json::Value channels;
channels.append(channel);
_conn.publish(channels, msg);
@ -260,7 +260,7 @@ namespace
ix::msleep(50);
_conn.disconnect();
_conn.setEventCallback([]
(ix::CobraConnectionEventType eventType,
const std::string& errMsg,
@ -305,7 +305,7 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
{
if (chatA.isReady() && chatB.isReady()) break;
ix::msleep(10);
timeout -= 10;
if (timeout <= 0)
{
@ -329,7 +329,7 @@ TEST_CASE("Cobra_chat", "[cobra_chat]")
while (chatA.hasPendingMessages() || chatB.hasPendingMessages())
{
ix::msleep(10);
timeout -= 10;
if (timeout <= 0)
{

View File

@ -137,13 +137,13 @@ TEST_CASE("Cobra_Metrics_Publisher", "[cobra]")
std::thread bgThread(&startSubscriber, endpoint);
int timeout = 10 * 1000; // 10s
// Wait until the subscriber is ready (authenticated + subscription successful)
while (!gSubscriberConnectedAndSubscribed)
{
std::chrono::duration<double, std::milli> duration(10);
std::this_thread::sleep_for(duration);
timeout -= 10;
if (timeout <= 0)
{

View File

@ -23,7 +23,6 @@ namespace ix
int getAnyFreePort()
{
int defaultPort = 8090;
int sockfd;
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
@ -89,5 +88,3 @@ namespace ix
return -1;
}
} // namespace ix

View File

@ -28,7 +28,6 @@ namespace
void stop();
void stop(uint16_t code, const std::string& reason);
bool isReady() const;
void sendMessage(const std::string& text);
uint16_t getCloseCode();
const std::string& getCloseReason();
@ -171,11 +170,6 @@ namespace
_webSocket.start();
}
void WebSocketClient::sendMessage(const std::string& text)
{
_webSocket.send(text);
}
bool startServer(ix::WebSocketServer& server,
uint16_t& receivedCloseCode,
std::string& receivedCloseReason,

View File

@ -112,6 +112,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
auto lineResult = socket->readLine(isCancellationRequested);
auto lineValid = lineResult.first;
REQUIRE(lineValid);
auto line = lineResult.second;
int status = -1;
@ -149,6 +151,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
auto lineResult = socket->readLine(isCancellationRequested);
auto lineValid = lineResult.first;
REQUIRE(lineValid);
auto line = lineResult.second;
int status = -1;
@ -190,6 +194,8 @@ TEST_CASE("Websocket_server", "[websocket_server]")
auto lineResult = socket->readLine(isCancellationRequested);
auto lineValid = lineResult.first;
REQUIRE(lineValid);
auto line = lineResult.second;
int status = -1;