cleanup, remove dead method
This commit is contained in:
parent
fe700d1e7b
commit
5b6fdb6526
@ -12,7 +12,7 @@ set (CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
|
|
||||||
# -Wshorten-64-to-32 does not work with clang
|
# -Wshorten-64-to-32 does not work with clang
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshorten-64-to-32")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||||
|
@ -287,12 +287,6 @@ namespace ix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketTransport::appendToSendBuffer(const std::vector<uint8_t>& buffer)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_txbufMutex);
|
|
||||||
_txbuf.insert(_txbuf.end(), buffer.begin(), buffer.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebSocketTransport::unmaskReceiveBuffer(const wsheader_type& ws)
|
void WebSocketTransport::unmaskReceiveBuffer(const wsheader_type& ws)
|
||||||
{
|
{
|
||||||
if (ws.mask)
|
if (ws.mask)
|
||||||
|
@ -174,7 +174,6 @@ namespace ix
|
|||||||
std::string::const_iterator end,
|
std::string::const_iterator end,
|
||||||
uint64_t message_size,
|
uint64_t message_size,
|
||||||
uint8_t masking_key[4]);
|
uint8_t masking_key[4]);
|
||||||
void appendToSendBuffer(const std::vector<uint8_t>& buffer);
|
|
||||||
|
|
||||||
unsigned getRandomUnsigned();
|
unsigned getRandomUnsigned();
|
||||||
void unmaskReceiveBuffer(const wsheader_type& ws);
|
void unmaskReceiveBuffer(const wsheader_type& ws);
|
||||||
|
@ -29,6 +29,7 @@ set (SOURCES
|
|||||||
|
|
||||||
IXDNSLookupTest.cpp
|
IXDNSLookupTest.cpp
|
||||||
IXSocketTest.cpp
|
IXSocketTest.cpp
|
||||||
|
IXSocketConnectTest.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Some unittest don't work on windows yet
|
# Some unittest don't work on windows yet
|
||||||
|
43
test/IXSocketConnectTest.cpp
Normal file
43
test/IXSocketConnectTest.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* IXSocketConnectTest.cpp
|
||||||
|
* Author: Benjamin Sergeant
|
||||||
|
* Copyright (c) 2018 Machine Zone. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "IXTest.h"
|
||||||
|
#include <ixwebsocket/IXSocketConnect.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace ix;
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("socket_connect", "[net]")
|
||||||
|
{
|
||||||
|
SECTION("Test connecting to a known hostname")
|
||||||
|
{
|
||||||
|
std::string errMsg;
|
||||||
|
int fd = SocketConnect::connect("www.google.com", 80, errMsg, [] { return false; });
|
||||||
|
std::cerr << "Error message: " << errMsg << std::endl;
|
||||||
|
REQUIRE(fd != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test connecting to a non-existing hostname")
|
||||||
|
{
|
||||||
|
std::string errMsg;
|
||||||
|
std::string hostname("12313lhjlkjhopiupoijlkasdckljqwehrlkqjwehraospidcuaposidcasdc");
|
||||||
|
int fd = SocketConnect::connect(hostname, 80, errMsg, [] { return false; });
|
||||||
|
std::cerr << "Error message: " << errMsg << std::endl;
|
||||||
|
REQUIRE(fd == -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Test connecting to a good hostname, with cancellation")
|
||||||
|
{
|
||||||
|
std::string errMsg;
|
||||||
|
// The callback returning true means we are requesting cancellation
|
||||||
|
int fd = SocketConnect::connect("www.google.com", 80, errMsg, [] { return true; });
|
||||||
|
std::cerr << "Error message: " << errMsg << std::endl;
|
||||||
|
REQUIRE(fd == -1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user