#include <algorithm>
#include <string>
#include <utility>
#include <gtest/gtest.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "../internal.h"
#include "../test/file_util.h"
#include "../test/test_util.h"
#if !defined(OPENSSL_WINDOWS)
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <poll.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#else
#include <io.h>
#include <fcntl.h>
OPENSSL_MSVC_PRAGMA(warning(push, 3))
#include <winsock2.h>
#include <ws2tcpip.h>
OPENSSL_MSVC_PRAGMA(warning(pop))
#endif
#if !defined(OPENSSL_WINDOWS)
Socket;
#define INVALID_SOCKET …
static int closesocket(int sock) { … }
static std::string LastSocketError() { … }
static const int kOpenReadOnlyBinary = …;
static const int kOpenReadOnlyText = …;
#else
using Socket = SOCKET;
static std::string LastSocketError() {
char buf[DECIMAL_SIZE(int) + 1];
snprintf(buf, sizeof(buf), "%d", WSAGetLastError());
return buf;
}
static const int kOpenReadOnlyBinary = _O_RDONLY | _O_BINARY;
static const int kOpenReadOnlyText = O_RDONLY | _O_TEXT;
#endif
class OwnedSocket { … };
struct SockaddrStorage { … };
static OwnedSocket Bind(int family, const sockaddr *addr, socklen_t addr_len) { … }
static OwnedSocket ListenLoopback(int backlog) { … }
static bool SocketSetNonBlocking(Socket sock) { … }
enum class WaitType { … };
static bool WaitForSocket(Socket sock, WaitType wait_type) { … }
TEST(BIOTest, SocketConnect) { … }
TEST(BIOTest, SocketNonBlocking) { … }
TEST(BIOTest, Printf) { … }
TEST(BIOTest, ReadASN1) { … }
TEST(BIOTest, MemReadOnly) { … }
TEST(BIOTest, MemWritable) { … }
TEST(BIOTest, Gets) { … }
TEST(BIOTest, FileMode) { … }
class BIOPairTest : public testing::TestWithParam<bool> { … };
TEST_P(BIOPairTest, TestPair) { … }
INSTANTIATE_TEST_SUITE_P(…);