24 #define xmlrpcpp_EXPORTS // we are mocking XmlRpcSocket, define the symbol in order to export XmlRpcSocket class 26 #undef xmlrpcpp_EXPORTS 36 #include <gtest/gtest.h> 52 std::snprintf(err,
sizeof(err),
"%s", strerror(error));
53 return std::string(err);
56 #define EXPECT_PROLOGUE(name) \ 57 EXPECT_EQ(0, name##_calls) \ 58 << "Test error; cannont expect " #name " more than once"; 66 EXPECT_EQ(close_fd, fd);
189 const std::string& host,
214 const std::string&
s,
239 const std::string&
s,
void Expect_listen(int fd, int backlog, bool ret)
static bool setReuseAddr(int socket)
void Expect_setNonBlocking(int fd, bool ret)
static int get_port(int socket)
static int accept(int socket)
Accept a client connection request.
void Expect_setReuseAddr(int fd, bool ret)
void Expect_bind(int fd, int port, bool ret)
static bool nbRead(int socket, std::string &s, bool *eof)
Read text from the specified socket. Returns false on error.
static std::string getErrorMsg()
Returns message corresponding to last error.
void Expect_close(int fd)
static bool nbWrite(int socket, const std::string &s, int *bytesSoFar)
Write text to the specified socket. Returns false on error.
void Expect_connect(int fd, const std::string &host, int port, bool ret)
static bool bind(int socket, int port)
Bind to a specified port.
static int getError()
Returns last errno.
void Expect_getError(int ret)
static bool connect(int socket, const std::string &host, int port)
Connect a socket to a server (from a client)
std::deque< int > close_calls
static bool listen(int socket, int backlog)
Set socket in listen mode.
#define EXPECT_PROLOGUE(name)
void Expect_get_port(int socket, int ret)
static int socket()
Creates a stream (TCP) socket. Returns -1 on failure.
static void close(int socket)
Closes a socket.
static bool setNonBlocking(int socket)
Sets a stream (TCP) socket to perform non-blocking IO. Returns false on failure.
void Expect_nbRead(int fd, const std::string &s, bool eof, bool ret)
void Expect_socket(int ret)
void Expect_accept(int fd, int ret)
void Expect_nbWrite(int fd, const std::string &s, int bytes, bool ret)