Fixed compilation issues in unit tests.

This commit is contained in:
Vincent Richard 2012-12-11 22:02:47 +01:00
parent dc791215f5
commit 7fdcc31ab3
3 changed files with 56 additions and 12 deletions

View File

@ -51,8 +51,10 @@ VMIME_TEST_SUITE_BEGIN
socket->localSend("123 Response Text\r\n");
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
VASSERT_EQ("Lines", 1, resp->getLineCount());
@ -67,8 +69,10 @@ VMIME_TEST_SUITE_BEGIN
socket->localSend("123 Response Text\n");
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
VASSERT_EQ("Lines", 1, resp->getLineCount());
@ -87,8 +91,10 @@ VMIME_TEST_SUITE_BEGIN
"123 Text\r\n"
);
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
VASSERT_EQ("Lines", 2, resp->getLineCount());
@ -113,8 +119,10 @@ VMIME_TEST_SUITE_BEGIN
"456 Text\r\n"
);
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 0, resp->getCode());
VASSERT_EQ("Lines", 2, resp->getLineCount());
@ -140,8 +148,10 @@ VMIME_TEST_SUITE_BEGIN
// Missing data
);
vmime::net::smtp::SMTPResponse::state responseState;
VASSERT_THROW("Incomplete response",
vmime::net::smtp::SMTPResponse::readResponse(socket, toh),
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState),
vmime::exceptions::operation_timed_out);
}
@ -157,8 +167,10 @@ VMIME_TEST_SUITE_BEGIN
"More information\r\n"
);
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 334, resp->getCode());
VASSERT_EQ("Lines", 1, resp->getLineCount());
@ -176,8 +188,10 @@ VMIME_TEST_SUITE_BEGIN
"250\r\n"
);
vmime::net::smtp::SMTPResponse::state responseState;
vmime::ref <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh);
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 250, resp->getCode());
VASSERT_EQ("Lines", 1, resp->getLineCount());

View File

@ -57,6 +57,24 @@ testSocket::size_type testSocket::getBlockSize() const
}
unsigned int testSocket::getStatus() const
{
return 0;
}
const vmime::string testSocket::getPeerName() const
{
return "test.vmime.org";
}
const vmime::string testSocket::getPeerAddress() const
{
return "127.0.0.1";
}
void testSocket::receive(vmime::string& buffer)
{
buffer = m_inBuffer;
@ -72,9 +90,9 @@ void testSocket::send(const vmime::string& buffer)
}
int testSocket::receiveRaw(char* buffer, const int count)
testSocket::size_type testSocket::receiveRaw(char* buffer, const size_type count)
{
const int n = std::min(count, static_cast <int>(m_inBuffer.size()));
const size_type n = std::min(count, static_cast <size_type>(m_inBuffer.size()));
std::copy(m_inBuffer.begin(), m_inBuffer.begin() + n, buffer);
m_inBuffer.erase(m_inBuffer.begin(), m_inBuffer.begin() + n);
@ -83,12 +101,18 @@ int testSocket::receiveRaw(char* buffer, const int count)
}
void testSocket::sendRaw(const char* buffer, const int count)
void testSocket::sendRaw(const char* buffer, const size_type count)
{
send(vmime::string(buffer, count));
}
testSocket::size_type testSocket::sendRawNonBlocking(const char* buffer, const size_type count)
{
sendRaw(buffer, count);
}
void testSocket::localSend(const vmime::string& buffer)
{
m_inBuffer += buffer;

View File

@ -213,11 +213,17 @@ public:
void receive(vmime::string& buffer);
void send(const vmime::string& buffer);
int receiveRaw(char* buffer, const int count);
void sendRaw(const char* buffer, const int count);
size_type receiveRaw(char* buffer, const size_type count);
void sendRaw(const char* buffer, const size_type count);
size_type sendRawNonBlocking(const char* buffer, const size_type count);
size_type getBlockSize() const;
unsigned int getStatus() const;
const vmime::string getPeerName() const;
const vmime::string getPeerAddress() const;
/** Send data to client.
*
* @buffer data to send