aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/net/smtp/SMTPTransportTestUtils.hpp24
-rw-r--r--tests/parser/charsetFilteredOutputStreamTest.cpp6
-rw-r--r--tests/parser/charsetTestSuites.hpp2
-rw-r--r--tests/parser/messageTest.cpp4
-rw-r--r--tests/testRunner.cpp4
-rw-r--r--tests/testUtils.cpp32
-rw-r--r--tests/testUtils.hpp17
-rw-r--r--tests/utility/filteredStreamTest.cpp14
-rw-r--r--tests/utility/outputStreamByteArrayAdapterTest.cpp2
-rw-r--r--tests/utility/outputStreamSocketAdapterTest.cpp2
-rw-r--r--tests/utility/outputStreamStringAdapterTest.cpp10
-rw-r--r--tests/utility/seekableInputStreamRegionAdapterTest.cpp29
-rw-r--r--tests/utility/stringProxyTest.cpp32
-rw-r--r--tests/utility/stringUtilsTest.cpp43
14 files changed, 136 insertions, 85 deletions
diff --git a/tests/net/smtp/SMTPTransportTestUtils.hpp b/tests/net/smtp/SMTPTransportTestUtils.hpp
index dd7afeb5..c3296092 100644
--- a/tests/net/smtp/SMTPTransportTestUtils.hpp
+++ b/tests/net/smtp/SMTPTransportTestUtils.hpp
@@ -131,8 +131,8 @@ public:
}
else if (cmd == "RCPT")
{
- const vmime::string::size_type lt = line.find('<');
- const vmime::string::size_type gt = line.find('>');
+ const vmime::size_t lt = line.find('<');
+ const vmime::size_t gt = line.find('>');
VASSERT("RCPT <", lt != vmime::string::npos);
VASSERT("RCPT >", gt != vmime::string::npos);
@@ -261,8 +261,8 @@ public:
{
if (m_bdatChunkReceived != m_bdatChunkSize)
{
- const size_type remaining = m_bdatChunkSize - m_bdatChunkReceived;
- const size_type received = localReceiveRaw(NULL, remaining);
+ const size_t remaining = m_bdatChunkSize - m_bdatChunkReceived;
+ const size_t received = localReceiveRaw(NULL, remaining);
m_bdatChunkReceived += received;
}
@@ -408,7 +408,7 @@ class SMTPTestMessage : public vmime::message
{
public:
- vmime::utility::stream::size_type getChunkBufferSize() const
+ vmime::size_t getChunkBufferSize() const
{
static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(vmime::null);
return chunkStream.getBlockSize();
@@ -429,10 +429,9 @@ public:
return chunks;
}
- void generateImpl(const vmime::generationContext& /* ctx */,
- vmime::utility::outputStream& outputStream,
- const vmime::string::size_type /* curLinePos */ = 0,
- vmime::string::size_type* /* newLinePos */ = NULL) const
+ void generateImpl
+ (const vmime::generationContext& /* ctx */, vmime::utility::outputStream& outputStream,
+ const size_t /* curLinePos */ = 0, size_t* /* newLinePos */ = NULL) const
{
for (unsigned int i = 0, n = getChunks().size() ; i < n ; ++i)
{
@@ -576,16 +575,15 @@ class SMTPBigTestMessage : public vmime::message
{
public:
- vmime::utility::stream::size_type getGeneratedSize
- (const vmime::generationContext& /* ctx */)
+ size_t getGeneratedSize(const vmime::generationContext& /* ctx */)
{
return SIZE;
}
void generateImpl(const vmime::generationContext& /* ctx */,
vmime::utility::outputStream& outputStream,
- const vmime::string::size_type /* curLinePos */ = 0,
- vmime::string::size_type* /* newLinePos */ = NULL) const
+ const vmime::size_t /* curLinePos */ = 0,
+ vmime::size_t* /* newLinePos */ = NULL) const
{
for (unsigned int i = 0, n = SIZE ; i < n ; ++i)
outputStream.write("X", 1);
diff --git a/tests/parser/charsetFilteredOutputStreamTest.cpp b/tests/parser/charsetFilteredOutputStreamTest.cpp
index 4c91a71c..9b8397a8 100644
--- a/tests/parser/charsetFilteredOutputStreamTest.cpp
+++ b/tests/parser/charsetFilteredOutputStreamTest.cpp
@@ -85,7 +85,7 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::utility::inputStreamStringAdapter is(in);
- vmime::utility::stream::value_type buffer[16];
+ vmime::byte_t buffer[16];
for (int i = 0 ; !is.eof() ; ++i)
os->write(buffer, is.read(buffer, 1));
@@ -161,7 +161,7 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::utility::inputStreamStringAdapter is(in);
- vmime::utility::stream::value_type buffer[16];
+ vmime::byte_t buffer[16];
for (int i = 0 ; !is.eof() ; ++i)
os->write(buffer, is.read(buffer, 1));
@@ -201,7 +201,7 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::utility::inputStreamStringAdapter is(in);
- vmime::utility::stream::value_type buffer[16];
+ vmime::byte_t buffer[16];
for (int i = 0 ; !is.eof() ; ++i)
os->write(buffer, is.read(buffer, (i % 5) + 1));
diff --git a/tests/parser/charsetTestSuites.hpp b/tests/parser/charsetTestSuites.hpp
index b12b3e37..cb10e29e 100644
--- a/tests/parser/charsetTestSuites.hpp
+++ b/tests/parser/charsetTestSuites.hpp
@@ -100,4 +100,4 @@ static const charsetTestSuiteStruct charsetTestSuites[] =
};
-static const unsigned int charsetTestSuitesCount = sizeof(charsetTestSuites) / sizeof(charsetTestSuites[0]);
+static const vmime::size_t charsetTestSuitesCount = sizeof(charsetTestSuites) / sizeof(charsetTestSuites[0]);
diff --git a/tests/parser/messageTest.cpp b/tests/parser/messageTest.cpp
index a7a16813..3891b47e 100644
--- a/tests/parser/messageTest.cpp
+++ b/tests/parser/messageTest.cpp
@@ -44,8 +44,8 @@ VMIME_TEST_SUITE_BEGIN(messageTest)
textPart.generateIn(msg, msg);
// Estimated/computed generated size must be greater than the actual generated size
- const unsigned long genSize = msg->getGeneratedSize(ctx);
- const unsigned long actualSize = msg->generate().length();
+ const vmime::size_t genSize = msg->getGeneratedSize(ctx);
+ const vmime::size_t actualSize = msg->generate().length();
std::ostringstream oss;
oss << "estimated size (" << genSize << ") >= actual size (" << actualSize << ")";
diff --git a/tests/testRunner.cpp b/tests/testRunner.cpp
index 48a09d17..84f217a0 100644
--- a/tests/testRunner.cpp
+++ b/tests/testRunner.cpp
@@ -196,7 +196,7 @@ const std::string getNormalizedPath(const std::string& path)
{
std::string res = path;
- for (std::string::size_type i = 0, n = res.length() ; i < n ; ++i)
+ for (std::size_t i = 0, n = res.length() ; i < n ; ++i)
{
if (res[i] == '\\')
res[i] = '/';
@@ -208,7 +208,7 @@ const std::string getNormalizedPath(const std::string& path)
const std::string getFileNameFromPath(const std::string& path)
{
- const std::string::size_type pos = path.find_last_of('/');
+ const std::size_t pos = path.find_last_of('/');
if (pos == std::string::npos)
return "";
diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp
index c22649e6..437b476b 100644
--- a/tests/testUtils.cpp
+++ b/tests/testUtils.cpp
@@ -23,6 +23,10 @@
#include "testUtils.hpp"
+#include "vmime/utility/stringUtils.hpp"
+
+#include <cstring>
+
// testSocket
@@ -51,7 +55,7 @@ bool testSocket::isConnected() const
}
-testSocket::size_type testSocket::getBlockSize() const
+vmime::size_t testSocket::getBlockSize() const
{
return 16384;
}
@@ -90,9 +94,15 @@ void testSocket::send(const vmime::string& buffer)
}
-testSocket::size_type testSocket::receiveRaw(char* buffer, const size_type count)
+void testSocket::send(const char* str)
+{
+ sendRaw(reinterpret_cast <const vmime::byte_t*>(str), strlen(str));
+}
+
+
+vmime::size_t testSocket::receiveRaw(vmime::byte_t* buffer, const size_t count)
{
- const size_type n = std::min(count, static_cast <size_type>(m_inBuffer.size()));
+ const size_t n = std::min(count, static_cast <size_t>(m_inBuffer.size()));
std::copy(m_inBuffer.begin(), m_inBuffer.begin() + n, buffer);
m_inBuffer.erase(m_inBuffer.begin(), m_inBuffer.begin() + n);
@@ -101,13 +111,13 @@ testSocket::size_type testSocket::receiveRaw(char* buffer, const size_type count
}
-void testSocket::sendRaw(const char* buffer, const size_type count)
+void testSocket::sendRaw(const vmime::byte_t* buffer, const size_t count)
{
- send(vmime::string(buffer, count));
+ send(vmime::utility::stringUtils::makeStringFromBytes(buffer, count));
}
-testSocket::size_type testSocket::sendRawNonBlocking(const char* buffer, const size_type count)
+vmime::size_t testSocket::sendRawNonBlocking(const vmime::byte_t* buffer, const size_t count)
{
sendRaw(buffer, count);
return count;
@@ -129,7 +139,7 @@ void testSocket::localReceive(vmime::string& buffer)
bool testSocket::localReceiveLine(vmime::string& line)
{
- vmime::string::size_type eol;
+ vmime::size_t eol;
if ((eol = m_outBuffer.find('\n')) != vmime::string::npos)
{
@@ -147,9 +157,9 @@ bool testSocket::localReceiveLine(vmime::string& line)
}
-testSocket::size_type testSocket::localReceiveRaw(char* buffer, const size_type count)
+vmime::size_t testSocket::localReceiveRaw(vmime::byte_t* buffer, const size_t count)
{
- const size_type received = std::min(count, static_cast <size_type>(m_outBuffer.size()));
+ const size_t received = std::min(count, static_cast <size_t>(m_outBuffer.size()));
if (received != 0)
{
@@ -184,7 +194,7 @@ void lineBasedTestSocket::onDataReceived()
m_buffer += chunk;
- vmime::string::size_type eol;
+ vmime::size_t eol;
while ((eol = m_buffer.find('\n')) != vmime::string::npos)
{
@@ -217,7 +227,7 @@ bool lineBasedTestSocket::haveMoreLines() const
// testTimeoutHandler
-testTimeoutHandler::testTimeoutHandler(const unsigned int delay)
+testTimeoutHandler::testTimeoutHandler(const unsigned long delay)
: m_delay(delay), m_start(0)
{
}
diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp
index fdcca575..f0ecf454 100644
--- a/tests/testUtils.hpp
+++ b/tests/testUtils.hpp
@@ -250,12 +250,13 @@ public:
void receive(vmime::string& buffer);
void send(const vmime::string& buffer);
+ void send(const char* str);
- 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_t receiveRaw(vmime::byte_t* buffer, const size_t count);
+ void sendRaw(const vmime::byte_t* buffer, const size_t count);
+ size_t sendRawNonBlocking(const vmime::byte_t* buffer, const size_t count);
- size_type getBlockSize() const;
+ size_t getBlockSize() const;
unsigned int getStatus() const;
@@ -287,7 +288,7 @@ public:
* @param count number of bytes to receive
* @return number of bytes received
*/
- testSocket::size_type localReceiveRaw(char* buffer, const size_type count);
+ vmime::size_t localReceiveRaw(vmime::byte_t* buffer, const size_t count);
protected:
@@ -349,7 +350,7 @@ class testTimeoutHandler : public vmime::net::timeoutHandler
{
public:
- testTimeoutHandler(const unsigned int delay = 3);
+ testTimeoutHandler(const unsigned long delay = 3);
bool isTimeOut();
void resetTimeOut();
@@ -357,8 +358,8 @@ public:
private:
- unsigned int m_delay;
- unsigned int m_start;
+ unsigned long m_delay;
+ unsigned long m_start;
};
diff --git a/tests/utility/filteredStreamTest.cpp b/tests/utility/filteredStreamTest.cpp
index 76cb149b..ec1fc66a 100644
--- a/tests/utility/filteredStreamTest.cpp
+++ b/tests/utility/filteredStreamTest.cpp
@@ -24,6 +24,7 @@
#include "tests/testUtils.hpp"
#include "vmime/utility/filteredStream.hpp"
+#include "vmime/utility/stringUtils.hpp"
VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
@@ -45,7 +46,7 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
private:
std::vector <std::string> m_chunks;
- std::vector <std::string>::size_type m_index;
+ size_t m_index;
public:
@@ -56,7 +57,7 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
bool eof() const { return (m_index >= m_chunks.size()); }
void reset() { m_index = 0; }
- size_type read(value_type* const data, const size_type /* count */)
+ vmime::size_t read(vmime::byte_t* const data, const vmime::size_t /* count */)
{
if (eof())
return 0;
@@ -72,7 +73,7 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
return chunk.length();
}
- size_type skip(const size_type /* count */)
+ vmime::size_t skip(const vmime::size_t /* count */)
{
// Not supported
return 0;
@@ -82,15 +83,14 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
const std::string readWhole(vmime::utility::inputStream& is)
{
- vmime::utility::stream::value_type buffer[256];
+ vmime::byte_t buffer[256];
std::string whole;
while (!is.eof())
{
- const vmime::utility::stream::size_type read =
- is.read(buffer, sizeof(buffer));
+ const vmime::size_t read = is.read(buffer, sizeof(buffer));
- whole += std::string(buffer, read);
+ whole += vmime::utility::stringUtils::makeStringFromBytes(buffer, read);
}
return (whole);
diff --git a/tests/utility/outputStreamByteArrayAdapterTest.cpp b/tests/utility/outputStreamByteArrayAdapterTest.cpp
index 93e49fa1..b14d0a39 100644
--- a/tests/utility/outputStreamByteArrayAdapterTest.cpp
+++ b/tests/utility/outputStreamByteArrayAdapterTest.cpp
@@ -52,7 +52,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
void testWriteBinary()
{
- const vmime::string::value_type binaryData[] =
+ const char binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
diff --git a/tests/utility/outputStreamSocketAdapterTest.cpp b/tests/utility/outputStreamSocketAdapterTest.cpp
index 417eff8b..4920a75c 100644
--- a/tests/utility/outputStreamSocketAdapterTest.cpp
+++ b/tests/utility/outputStreamSocketAdapterTest.cpp
@@ -51,7 +51,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
void testWriteBinary()
{
- const vmime::string::value_type binaryData[] =
+ const char binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
diff --git a/tests/utility/outputStreamStringAdapterTest.cpp b/tests/utility/outputStreamStringAdapterTest.cpp
index 71ab9b38..1cd3b3a0 100644
--- a/tests/utility/outputStreamStringAdapterTest.cpp
+++ b/tests/utility/outputStreamStringAdapterTest.cpp
@@ -43,16 +43,18 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
stream << "additional data";
stream.flush();
- VASSERT_EQ("Write 1", "initial dataadditional data", str);
+ VASSERT_EQ("Write 1 len", 27, str.length());
+ VASSERT_EQ("Write 1 data", "initial dataadditional data", str);
- stream.write("more data", 9);
+ stream.write("more data");
- VASSERT_EQ("Write 2", "initial dataadditional datamore data", str);
+ VASSERT_EQ("Write 2 len", 36, str.length());
+ VASSERT_EQ("Write 2 data", "initial dataadditional datamore data", str);
}
void testWriteBinary()
{
- const vmime::string::value_type binaryData[] =
+ const vmime::byte_t binaryData[] =
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
diff --git a/tests/utility/seekableInputStreamRegionAdapterTest.cpp b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
index 1c33c056..d62e062f 100644
--- a/tests/utility/seekableInputStreamRegionAdapterTest.cpp
+++ b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
@@ -25,6 +25,7 @@
#include "vmime/utility/inputStreamStringAdapter.hpp"
#include "vmime/utility/seekableInputStreamRegionAdapter.hpp"
+#include "vmime/utility/stringUtils.hpp"
using namespace vmime::utility;
@@ -88,14 +89,15 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
stream->seek(5);
- stream::value_type buffer[100];
+ vmime::byte_t buffer[100];
std::fill(vmime::begin(buffer), vmime::end(buffer), 0);
- stream::size_type read = stream->read(buffer, 6);
+ vmime::size_t read = stream->read(buffer, 6);
VASSERT_EQ("Pos", 11, stream->getPosition());
VASSERT_EQ("Read", 6, read);
VASSERT_TRUE("EOF", stream->eof());
- VASSERT_EQ("Buffer", "BUFFER", vmime::string(buffer, 0, 6));
+ VASSERT_EQ("Buffer", "BUFFER",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer, 6));
}
void testSkip()
@@ -107,14 +109,15 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Pos 1", 5, stream->getPosition());
VASSERT_FALSE("EOF 1", stream->eof());
- stream::value_type buffer[100];
+ vmime::byte_t buffer[100];
std::fill(vmime::begin(buffer), vmime::end(buffer), 0);
- stream::size_type read = stream->read(buffer, 3);
+ vmime::size_t read = stream->read(buffer, 3);
VASSERT_EQ("Pos 2", 8, stream->getPosition());
VASSERT_EQ("Read", 3, read);
VASSERT_FALSE("EOF 2", stream->eof());
- VASSERT_EQ("Buffer", "BUF", vmime::string(buffer, 0, 3));
+ VASSERT_EQ("Buffer", "BUF",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer, 3));
stream->skip(50);
@@ -143,16 +146,18 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
stream->seek(5);
- stream::value_type buffer1[100];
+ vmime::byte_t buffer1[100];
std::fill(vmime::begin(buffer1), vmime::end(buffer1), 0);
- stream::size_type read = ustream->read(buffer1, 7);
+ vmime::size_t read = ustream->read(buffer1, 7);
- stream::value_type buffer2[100];
+ vmime::byte_t buffer2[100];
std::fill(vmime::begin(buffer2), vmime::end(buffer2), 0);
- stream::size_type read2 = stream->read(buffer2, 6);
+ vmime::size_t read2 = stream->read(buffer2, 6);
- VASSERT_EQ("Buffer 1", "THIS IS", vmime::string(buffer1, 0, 7));
- VASSERT_EQ("Buffer 2", "BUFFER", vmime::string(buffer2, 0, 6));
+ VASSERT_EQ("Buffer 1", "THIS IS",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer1, 7));
+ VASSERT_EQ("Buffer 2", "BUFFER",
+ vmime::utility::stringUtils::makeStringFromBytes(buffer2, 6));
// ...but the underlying stream position is affected by read operations
// from the region adapter (FIXME?)
diff --git a/tests/utility/stringProxyTest.cpp b/tests/utility/stringProxyTest.cpp
index 0d888f6a..d6513681 100644
--- a/tests/utility/stringProxyTest.cpp
+++ b/tests/utility/stringProxyTest.cpp
@@ -45,9 +45,9 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
{
vmime::utility::stringProxy s;
- VASSERT_EQ("1", static_cast <vmime::utility::stringProxy::size_type>(0), s.length());
- VASSERT_EQ("2", static_cast <vmime::utility::stringProxy::size_type>(0), s.start());
- VASSERT_EQ("3", static_cast <vmime::utility::stringProxy::size_type>(0), s.end());
+ VASSERT_EQ("1", static_cast <vmime::size_t>(0), s.length());
+ VASSERT_EQ("2", static_cast <vmime::size_t>(0), s.start());
+ VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
void testConstruct2()
@@ -57,20 +57,20 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
vmime::utility::stringProxy s1(str);
VASSERT_EQ("1", str.length(), s1.length());
- VASSERT_EQ("2", static_cast <vmime::utility::stringProxy::size_type>(0), s1.start());
+ VASSERT_EQ("2", static_cast <vmime::size_t>(0), s1.start());
VASSERT_EQ("3", str.length(), s1.end());
vmime::utility::stringProxy s2(str, 10);
VASSERT_EQ("4", str.length() - 10, s2.length());
- VASSERT_EQ("5", static_cast <vmime::utility::stringProxy::size_type>(10), s2.start());
+ VASSERT_EQ("5", static_cast <vmime::size_t>(10), s2.start());
VASSERT_EQ("6", str.length(), s2.end());
vmime::utility::stringProxy s3(str, 10, 14);
- VASSERT_EQ("7", static_cast <vmime::utility::stringProxy::size_type>(4), s3.length());
- VASSERT_EQ("8", static_cast <vmime::utility::stringProxy::size_type>(10), s3.start());
- VASSERT_EQ("9", static_cast <vmime::utility::stringProxy::size_type>(14), s3.end());
+ VASSERT_EQ("7", static_cast <vmime::size_t>(4), s3.length());
+ VASSERT_EQ("8", static_cast <vmime::size_t>(10), s3.start());
+ VASSERT_EQ("9", static_cast <vmime::size_t>(14), s3.end());
VASSERT_EQ("10", 't', *s3.it_begin());
VASSERT_EQ("11", 'e', *(s3.it_begin() + 1));
@@ -85,9 +85,9 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
s.detach();
- VASSERT_EQ("1", static_cast <vmime::utility::stringProxy::size_type>(0), s.length());
- VASSERT_EQ("2", static_cast <vmime::utility::stringProxy::size_type>(0), s.start());
- VASSERT_EQ("3", static_cast <vmime::utility::stringProxy::size_type>(0), s.end());
+ VASSERT_EQ("1", static_cast <vmime::size_t>(0), s.length());
+ VASSERT_EQ("2", static_cast <vmime::size_t>(0), s.start());
+ VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
void testSet()
@@ -98,22 +98,22 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
s1.set(str);
VASSERT_EQ("1", str.length(), s1.length());
- VASSERT_EQ("2", static_cast <vmime::utility::stringProxy::size_type>(0), s1.start());
+ VASSERT_EQ("2", static_cast <vmime::size_t>(0), s1.start());
VASSERT_EQ("3", str.length(), s1.end());
vmime::utility::stringProxy s2;
s2.set(str, 10);
VASSERT_EQ("4", str.length() - 10, s2.length());
- VASSERT_EQ("5", static_cast <vmime::utility::stringProxy::size_type>(10), s2.start());
+ VASSERT_EQ("5", static_cast <vmime::size_t>(10), s2.start());
VASSERT_EQ("6", str.length(), s2.end());
vmime::utility::stringProxy s3;
s3.set(str, 10, 14);
- VASSERT_EQ("7", static_cast <vmime::utility::stringProxy::size_type>(4), s3.length());
- VASSERT_EQ("8", static_cast <vmime::utility::stringProxy::size_type>(10), s3.start());
- VASSERT_EQ("9", static_cast <vmime::utility::stringProxy::size_type>(14), s3.end());
+ VASSERT_EQ("7", static_cast <vmime::size_t>(4), s3.length());
+ VASSERT_EQ("8", static_cast <vmime::size_t>(10), s3.start());
+ VASSERT_EQ("9", static_cast <vmime::size_t>(14), s3.end());
VASSERT_EQ("10", 't', *s3.it_begin());
VASSERT_EQ("11", 'e', *(s3.it_begin() + 1));
diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp
index efd623db..a21c2742 100644
--- a/tests/utility/stringUtilsTest.cpp
+++ b/tests/utility/stringUtilsTest.cpp
@@ -29,6 +29,9 @@
VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VMIME_TEST_LIST_BEGIN
+ VMIME_TEST(testMakeStringFromBytes)
+ VMIME_TEST(testAppendBytesToString)
+
VMIME_TEST(testIsStringEqualNoCase1)
VMIME_TEST(testIsStringEqualNoCase2)
VMIME_TEST(testIsStringEqualNoCase3)
@@ -46,6 +49,38 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
typedef vmime::utility::stringUtils stringUtils;
+ void testMakeStringFromBytes()
+ {
+ vmime::byte_t bytes[] = { 0x12, 0x34, 0x56, 0x78 };
+ vmime::string str = vmime::utility::stringUtils::makeStringFromBytes(bytes, 3);
+
+ VASSERT_EQ("length", 3, str.length());
+ VASSERT_EQ("byte1", '\x12', str[0]);
+ VASSERT_EQ("byte2", '\x34', str[1]);
+ VASSERT_EQ("byte3", '\x56', str[2]);
+ }
+
+ void testAppendBytesToString()
+ {
+ vmime::byte_t bytes[] = { 0x42, 0x56, 0x12, 0x00, 'f', 'o', 'o' };
+
+ vmime::string str = "test";
+ vmime::utility::stringUtils::appendBytesToString(str, bytes, 7);
+
+ VASSERT_EQ("length", 4 + 7, str.length());
+ VASSERT_EQ("byte1", 't', str[0]);
+ VASSERT_EQ("byte2", 'e', str[1]);
+ VASSERT_EQ("byte3", 's', str[2]);
+ VASSERT_EQ("byte4", 't', str[3]);
+ VASSERT_EQ("byte5", '\x42', str[4]);
+ VASSERT_EQ("byte6", '\x56', str[5]);
+ VASSERT_EQ("byte7", '\x12', str[6]);
+ VASSERT_EQ("byte8", '\0', str[7]);
+ VASSERT_EQ("byte9", 'f', str[8]);
+ VASSERT_EQ("byte10", 'o', str[9]);
+ VASSERT_EQ("byte11", 'o', str[10]);
+ }
+
void testIsStringEqualNoCase1()
{
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3));
@@ -101,19 +136,19 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
void testCountASCIIChars()
{
vmime::string str1("foo");
- VASSERT_EQ("1", static_cast <vmime::string::size_type>(3),
+ VASSERT_EQ("1", static_cast <vmime::size_t>(3),
stringUtils::countASCIIchars(str1.begin(), str1.end()));
vmime::string str2("f=?oo");
- VASSERT_EQ("2", static_cast <vmime::string::size_type>(3 + 1),
+ VASSERT_EQ("2", static_cast <vmime::size_t>(3 + 1),
stringUtils::countASCIIchars(str2.begin(), str2.end()));
vmime::string str3("foo\x7f");
- VASSERT_EQ("3", static_cast <vmime::string::size_type>(4),
+ VASSERT_EQ("3", static_cast <vmime::size_t>(4),
stringUtils::countASCIIchars(str3.begin(), str3.end()));
vmime::string str4("foo\x80");
- VASSERT_EQ("4", static_cast <vmime::string::size_type>(3),
+ VASSERT_EQ("4", static_cast <vmime::size_t>(3),
stringUtils::countASCIIchars(str4.begin(), str4.end()));
}