aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2018-09-07 20:32:51 +0200
committerGitHub <[email protected]>2018-09-07 20:32:51 +0200
commit71968d978daea9beffdc22522e8e9a29d52c3e9e (patch)
tree48854151c452290f9e174765da3320ea845d5c50 /tests/utility
parentAdd SMTPS with AUTH PLAIN without SASL (diff)
parentUseless mutex does not make nl_langinfo() thread-safe. (diff)
downloadvmime-71968d978daea9beffdc22522e8e9a29d52c3e9e.tar.gz
vmime-71968d978daea9beffdc22522e8e9a29d52c3e9e.zip
Merge branch 'master' into master
Diffstat (limited to 'tests/utility')
-rw-r--r--tests/utility/datetimeUtilsTest.cpp43
-rw-r--r--tests/utility/encoder/b64EncoderTest.cpp55
-rw-r--r--tests/utility/encoder/encoderFactoryTest.cpp10
-rw-r--r--tests/utility/encoder/encoderTestUtils.hpp31
-rw-r--r--tests/utility/encoder/qpEncoderTest.cpp115
-rw-r--r--tests/utility/filteredStreamTest.cpp105
-rw-r--r--tests/utility/outputStreamByteArrayAdapterTest.cpp15
-rw-r--r--tests/utility/outputStreamSocketAdapterTest.cpp15
-rw-r--r--tests/utility/outputStreamStringAdapterTest.cpp15
-rw-r--r--tests/utility/parserInputStreamAdapterTest.cpp6
-rw-r--r--tests/utility/pathTest.cpp79
-rw-r--r--tests/utility/seekableInputStreamRegionAdapterTest.cpp57
-rw-r--r--tests/utility/stringProxyTest.cpp31
-rw-r--r--tests/utility/stringUtilsTest.cpp86
-rw-r--r--tests/utility/urlTest.cpp100
15 files changed, 431 insertions, 332 deletions
diff --git a/tests/utility/datetimeUtilsTest.cpp b/tests/utility/datetimeUtilsTest.cpp
index 1e21c5f9..77ce2425 100644
--- a/tests/utility/datetimeUtilsTest.cpp
+++ b/tests/utility/datetimeUtilsTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -43,8 +43,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
typedef vmime::utility::datetimeUtils datetimeUtils;
- void testIsLeapYear()
- {
+ void testIsLeapYear() {
+
VASSERT_EQ("1", false, datetimeUtils::isLeapYear(1999));
VASSERT_EQ("2", false, datetimeUtils::isLeapYear(1800));
VASSERT_EQ("3", false, datetimeUtils::isLeapYear(1900));
@@ -55,8 +55,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", true, datetimeUtils::isLeapYear(2000));
}
- void testGetDaysInMonth()
- {
+ void testGetDaysInMonth() {
+
VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2006, 1));
VASSERT_EQ("2", 28, datetimeUtils::getDaysInMonth(2006, 2));
VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2006, 3));
@@ -71,8 +71,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2006, 12));
}
- void testGetDaysInMonthLeapYear()
- {
+ void testGetDaysInMonthLeapYear() {
+
VASSERT_EQ("1", 31, datetimeUtils::getDaysInMonth(2004, 1));
VASSERT_EQ("2", 29, datetimeUtils::getDaysInMonth(2004, 2));
VASSERT_EQ("3", 31, datetimeUtils::getDaysInMonth(2004, 3));
@@ -87,13 +87,11 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("12", 31, datetimeUtils::getDaysInMonth(2004, 12));
}
- void testToUniversalTime()
- {
- const vmime::datetime local
- (2005, 12, 2, 12, 34, 56, -789);
+ void testToUniversalTime() {
+
+ const vmime::datetime local(2005, 12, 2, 12, 34, 56, -789);
- const vmime::datetime gmt =
- datetimeUtils::toUniversalTime(local);
+ const vmime::datetime gmt = datetimeUtils::toUniversalTime(local);
// 789 is 13 hours, 9 minutes later
VASSERT_EQ("1", 2005, gmt.getYear());
@@ -105,13 +103,11 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", 0, gmt.getZone());
}
- void testToLocalTime()
- {
- const vmime::datetime date
- (2005, 12, 2, 12, 34, 56, -120); // GMT-2
+ void testToLocalTime() {
- const vmime::datetime local =
- datetimeUtils::toLocalTime(date, 120); // GMT+2
+ const vmime::datetime date(2005, 12, 2, 12, 34, 56, -120); // GMT-2
+
+ const vmime::datetime local = datetimeUtils::toLocalTime(date, 120); // GMT+2
VASSERT_EQ("1", 2005, local.getYear());
VASSERT_EQ("2", 12, local.getMonth());
@@ -122,8 +118,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("7", 120, local.getZone());
}
- void testGetDayOfWeek()
- {
+ void testGetDayOfWeek() {
+
VASSERT_EQ("1", vmime::datetime::WEDNESDAY, datetimeUtils::getDayOfWeek(1969, 12, 31));
VASSERT_EQ("2", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(1976, 4, 9));
VASSERT_EQ("3", vmime::datetime::TUESDAY, datetimeUtils::getDayOfWeek(1987, 6, 23));
@@ -135,8 +131,8 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
VASSERT_EQ("9", vmime::datetime::FRIDAY, datetimeUtils::getDayOfWeek(2027, 3, 12));
}
- void testGetWeekOfYear()
- {
+ void testGetWeekOfYear() {
+
VASSERT_EQ("1.1", 52, datetimeUtils::getWeekOfYear(2003, 12, 27));
VASSERT_EQ("1.2", 52, datetimeUtils::getWeekOfYear(2003, 12, 28));
VASSERT_EQ("1.3", 1, datetimeUtils::getWeekOfYear(2003, 12, 29, true));
@@ -159,4 +155,3 @@ VMIME_TEST_SUITE_BEGIN(datetimeUtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/encoder/b64EncoderTest.cpp b/tests/utility/encoder/b64EncoderTest.cpp
index fa6fd766..36fa61ac 100644
--- a/tests/utility/encoder/b64EncoderTest.cpp
+++ b/tests/utility/encoder/b64EncoderTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,10 +33,10 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
VMIME_TEST_LIST_END
- void testBase64()
- {
- static const vmime::string testSuites[] =
- {
+ void testBase64() {
+
+ static const vmime::string testSuites[] = {
+
// Test 1
"",
@@ -96,8 +96,8 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
};
- for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) {
+
const vmime::string decoded = testSuites[i * 2];
const vmime::string encoded = testSuites[i * 2 + 1];
@@ -111,25 +111,36 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
VASSERT_EQ(oss.str() + "decoding", decoded, decode("base64", encoded));
// Multiple and successive encoding/decoding
- VASSERT_EQ(oss.str() + "multiple1", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple1",
+ decoded,
decode("base64",
- encode("base64", decoded)));
+ encode("base64", decoded))
+ );
- VASSERT_EQ(oss.str() + "multiple2", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple2",
+ decoded,
decode("base64",
decode("base64",
encode("base64",
- encode("base64", decoded)))));
+ encode("base64", decoded))))
+ );
- VASSERT_EQ(oss.str() + "multiple3", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple3",
+ decoded,
decode("base64",
decode("base64",
decode("base64",
encode("base64",
encode("base64",
- encode("base64", decoded)))))));
+ encode("base64", decoded))))))
+ );
- VASSERT_EQ(oss.str() + "multiple4", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple4",
+ decoded,
decode("base64",
decode("base64",
decode("base64",
@@ -137,17 +148,21 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
encode("base64",
encode("base64",
encode("base64",
- encode("base64", decoded)))))))));
+ encode("base64", decoded))))))))
+ );
- VASSERT(oss.str() + "encoded size",
+ VASSERT(
+ oss.str() + "encoded size",
getEncoder("base64")->getEncodedSize(decoded.length())
- >= encode("base64", decoded).length());
+ >= encode("base64", decoded).length()
+ );
- VASSERT(oss.str() + "decoded size",
+ VASSERT(
+ oss.str() + "decoded size",
getEncoder("base64")->getDecodedSize(encoded.length())
- >= decode("base64", encoded).length());
+ >= decode("base64", encoded).length()
+ );
}
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/encoder/encoderFactoryTest.cpp b/tests/utility/encoder/encoderFactoryTest.cpp
index ce50dc6a..916706c9 100644
--- a/tests/utility/encoder/encoderFactoryTest.cpp
+++ b/tests/utility/encoder/encoderFactoryTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -35,8 +35,8 @@ VMIME_TEST_SUITE_BEGIN(encoderFactoryTest)
VMIME_TEST_LIST_END
- void testNoDefaultEncoder()
- {
+ void testNoDefaultEncoder() {
+
vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
vmime::utility::encoder::encoderFactory::getInstance();
@@ -47,8 +47,8 @@ VMIME_TEST_SUITE_BEGIN(encoderFactoryTest)
);
}
- void testDefaultEncoder()
- {
+ void testDefaultEncoder() {
+
vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
vmime::utility::encoder::encoderFactory::getInstance();
diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp
index d74c4709..cc1141c7 100644
--- a/tests/utility/encoder/encoderTestUtils.hpp
+++ b/tests/utility/encoder/encoderTestUtils.hpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -23,25 +23,32 @@
// Helper function to obtain an encoder given its name
-static vmime::shared_ptr <vmime::utility::encoder::encoder> getEncoder(const vmime::string& name,
- int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
-{
+static vmime::shared_ptr <vmime::utility::encoder::encoder> getEncoder(
+ const vmime::string& name,
+ int maxLineLength = 0,
+ const vmime::propertySet props = vmime::propertySet()
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc =
vmime::utility::encoder::encoderFactory::getInstance()->create(name);
enc->getProperties() = props;
- if (maxLineLength != 0)
+ if (maxLineLength != 0) {
enc->getProperties()["maxlinelength"] = maxLineLength;
+ }
return enc;
}
// Encoding helper function
-static const vmime::string encode(const vmime::string& name, const vmime::string& in,
- int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
-{
+static const vmime::string encode(
+ const vmime::string& name, const vmime::string& in,
+ int maxLineLength = 0,
+ const vmime::propertySet props = vmime::propertySet()
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength, props);
vmime::utility::inputStreamStringAdapter vin(in);
@@ -56,8 +63,12 @@ static const vmime::string encode(const vmime::string& name, const vmime::string
// Decoding helper function
-static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0)
-{
+static const vmime::string decode(
+ const vmime::string& name,
+ const vmime::string& in,
+ int maxLineLength = 0
+) {
+
vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength);
vmime::utility::inputStreamStringAdapter vin(in);
diff --git a/tests/utility/encoder/qpEncoderTest.cpp b/tests/utility/encoder/qpEncoderTest.cpp
index e7d1bcd2..e4769475 100644
--- a/tests/utility/encoder/qpEncoderTest.cpp
+++ b/tests/utility/encoder/qpEncoderTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -38,10 +38,10 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VMIME_TEST_LIST_END
- void testQuotedPrintable()
- {
- static const vmime::string testSuites[] =
- {
+ void testQuotedPrintable() {
+
+ static const vmime::string testSuites[] = {
+
// Test 1
"",
@@ -94,8 +94,8 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
};
- for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i)
- {
+ for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) {
+
const vmime::string decoded = testSuites[i * 2];
const vmime::string encoded = testSuites[i * 2 + 1];
@@ -109,25 +109,36 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ(oss.str() + "decoding", decoded, decode("quoted-printable", encoded, 74));
// Multiple and successive encoding/decoding
- VASSERT_EQ(oss.str() + "multiple1", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple1",
+ decoded,
decode("quoted-printable",
- encode("quoted-printable", decoded)));
+ encode("quoted-printable", decoded))
+ );
- VASSERT_EQ(oss.str() + "multiple2", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple2",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))));
+ encode("quoted-printable", decoded))))
+ );
- VASSERT_EQ(oss.str() + "multiple3", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple3",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
decode("quoted-printable",
encode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))))));
+ encode("quoted-printable", decoded))))))
+ );
- VASSERT_EQ(oss.str() + "multiple4", decoded,
+ VASSERT_EQ(
+ oss.str() + "multiple4",
+ decoded,
decode("quoted-printable",
decode("quoted-printable",
decode("quoted-printable",
@@ -135,38 +146,50 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
encode("quoted-printable",
encode("quoted-printable",
encode("quoted-printable",
- encode("quoted-printable", decoded)))))))));
+ encode("quoted-printable", decoded))))))))
+ );
- VASSERT(oss.str() + "encoded size",
+ VASSERT(
+ oss.str() + "encoded size",
getEncoder("quoted-printable")->getEncodedSize(decoded.length())
- >= encode("quoted-printable", decoded).length());
+ >= encode("quoted-printable", decoded).length()
+ );
- VASSERT(oss.str() + "decoded size",
+ VASSERT(
+ oss.str() + "decoded size",
getEncoder("quoted-printable")->getDecodedSize(encoded.length())
- >= decode("quoted-printable", encoded).length());
+ >= decode("quoted-printable", encoded).length()
+ );
}
}
/** Tests Soft Line Breaks (RFC-2047/6.7(5). */
- void testQuotedPrintable_SoftLineBreaks()
- {
- VASSERT_EQ("1", "Now's the time=\r\n"
- " for all folk =\r\n"
- "to come to the=\r\n"
- " aid of their =\r\n"
- "country.",
- encode("quoted-printable", "Now's the time for all folk "
- "to come to the aid of their country.", 15));
+ void testQuotedPrintable_SoftLineBreaks() {
+
+ VASSERT_EQ(
+ "1",
+ "Now's the time=\r\n"
+ " for all folk =\r\n"
+ "to come to the=\r\n"
+ " aid of their =\r\n"
+ "country.",
+ encode(
+ "quoted-printable",
+ "Now's the time for all folk "
+ "to come to the aid of their country.",
+ 15
+ )
+ );
}
- void testQuotedPrintable_HardLineBreakEncode()
- {
+ void testQuotedPrintable_HardLineBreakEncode() {
+
const std::string data =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
- const std::string expected =
+ const std::string expected =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
@@ -178,14 +201,14 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ("1", expected, encode("quoted-printable", data, 35, encProps));
}
- void testQuotedPrintable_HardLineBreakDecode()
- {
+ void testQuotedPrintable_HardLineBreakDecode() {
+
const std::string expected =
"If you believe that truth=beauty,"
" then surely mathematics\r\nis the most"
" beautiful branch of philosophy.";
- const std::string data =
+ const std::string data =
"If you believe that truth=3Dbeauty=\r\n"
", then surely mathematics\r\n"
"is the most beautiful branch of ph=\r\n"
@@ -197,23 +220,29 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
/** In text mode, ensure line breaks in QP-encoded text are represented
* by a CRLF sequence, as per RFC-2047/6.7(4). */
- void testQuotedPrintable_CRLF()
- {
+ void testQuotedPrintable_CRLF() {
+
vmime::propertySet encProps;
// in "text" mode
encProps["text"] = true;
- VASSERT_EQ("text", "line1\r\nline2",
- encode("quoted-printable", "line1\r\nline2", 80, encProps));
+ VASSERT_EQ(
+ "text",
+ "line1\r\nline2",
+ encode("quoted-printable", "line1\r\nline2", 80, encProps)
+ );
// in "binary" mode
encProps["text"] = false;
- VASSERT_EQ("binary", "line1=0D=0Aline2",
- encode("quoted-printable", "line1\r\nline2", 80, encProps));
+ VASSERT_EQ(
+ "binary",
+ "line1=0D=0Aline2",
+ encode("quoted-printable", "line1\r\nline2", 80, encProps)
+ );
}
- void testQuotedPrintable_RFC2047()
- {
+ void testQuotedPrintable_RFC2047() {
+
/*
* The RFC (http://tools.ietf.org/html/rfc2047#section-5) says:
*
@@ -243,6 +272,4 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
VASSERT_EQ("especials.12", "=22", encode("quoted-printable", "\"", 10, encProps));
}
- // TODO: UUEncode
-
VMIME_TEST_SUITE_END
diff --git a/tests/utility/filteredStreamTest.cpp b/tests/utility/filteredStreamTest.cpp
index cedfab2a..ff3fb6a3 100644
--- a/tests/utility/filteredStreamTest.cpp
+++ b/tests/utility/filteredStreamTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -41,8 +41,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VMIME_TEST_LIST_END
- class chunkInputStream : public vmime::utility::inputStream
- {
+ class chunkInputStream : public vmime::utility::inputStream {
+
private:
std::vector <std::string> m_chunks;
@@ -57,10 +57,11 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
bool eof() const { return (m_index >= m_chunks.size()); }
void reset() { m_index = 0; }
- vmime::size_t read(vmime::byte_t* const data, const vmime::size_t /* count */)
- {
- if (eof())
+ vmime::size_t read(vmime::byte_t* const data, const vmime::size_t /* count */) {
+
+ if (eof()) {
return 0;
+ }
const std::string chunk = m_chunks[m_index];
@@ -73,37 +74,41 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
return chunk.length();
}
- vmime::size_t skip(const vmime::size_t /* count */)
- {
+ vmime::size_t skip(const vmime::size_t /* count */) {
+
// Not supported
return 0;
}
};
- const std::string readWhole(vmime::utility::inputStream& is)
- {
+ const std::string readWhole(vmime::utility::inputStream& is) {
+
vmime::byte_t buffer[256];
std::string whole;
- while (!is.eof())
- {
+ while (!is.eof()) {
+
const vmime::size_t read = is.read(buffer, sizeof(buffer));
whole += vmime::utility::stringUtils::makeStringFromBytes(buffer, read);
}
- return (whole);
+ return whole;
}
// dotFilteredInputStream
- void testDotFilteredInputStreamHelper
- (const std::string& number, const std::string& expected,
- const std::string& c1, const std::string& c2 = "",
- const std::string& c3 = "", const std::string& c4 = "")
- {
+ void testDotFilteredInputStreamHelper(
+ const std::string& number,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = ""
+ ) {
+
chunkInputStream cis;
cis.addChunk(c1);
if (!c2.empty()) cis.addChunk(c2);
@@ -120,8 +125,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, oss.str());
}
- void testDotFilteredInputStream()
- {
+ void testDotFilteredInputStream() {
+
testDotFilteredInputStreamHelper("1", "foo\n.bar", "foo\n..bar");
testDotFilteredInputStreamHelper("2", "foo\n.bar", "foo\n", "..bar");
testDotFilteredInputStreamHelper("3", "foo\n.bar", "foo\n.", ".bar");
@@ -140,11 +145,15 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// CRLFToLFFilteredOutputStream
template <typename FILTER>
- void testFilteredOutputStreamHelper
- (const std::string& number, const std::string& expected,
- const std::string& c1, const std::string& c2 = "",
- const std::string& c3 = "", const std::string& c4 = "")
- {
+ void testFilteredOutputStreamHelper(
+ const std::string& number,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = ""
+ ) {
+
std::ostringstream oss;
vmime::utility::outputStreamAdapter os(oss);
@@ -158,8 +167,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, oss.str());
}
- void testDotFilteredOutputStream()
- {
+ void testDotFilteredOutputStream() {
+
typedef vmime::utility::dotFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "foo\n..bar", "foo\n.bar");
@@ -177,8 +186,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testFilteredOutputStreamHelper<FILTER>("11", "this is the first line\x0d\x0a...\x0d\x0aone dot\x0d\x0a....\x0d\x0atwo dots\x0d\x0a.....\x0d\x0athree... \x0d\x0a...\x0d\x0a..\x0d\x0a", "this is the first line\x0d\x0a..\x0d\x0aone dot\x0d\x0a...\x0d\x0atwo dots\x0d\x0a....\x0d\x0athree... \x0d\x0a..\x0d\x0a.\x0d\x0a");
}
- void testCRLFToLFFilteredOutputStream()
- {
+ void testCRLFToLFFilteredOutputStream() {
+
typedef vmime::utility::CRLFToLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "foo\nbar", "foo\r\nbar");
@@ -193,12 +202,17 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// stopSequenceFilteredInputStream
template <int N>
- void testStopSequenceFISHelper
- (const std::string& number, const std::string& sequence,
- const std::string& expected, const std::string& c1,
- const std::string& c2 = "", const std::string& c3 = "",
- const std::string& c4 = "", const std::string& c5 = "")
- {
+ void testStopSequenceFISHelper(
+ const std::string& number,
+ const std::string& sequence,
+ const std::string& expected,
+ const std::string& c1,
+ const std::string& c2 = "",
+ const std::string& c3 = "",
+ const std::string& c4 = "",
+ const std::string& c5 = ""
+ ) {
+
chunkInputStream cis;
cis.addChunk(c1);
if (!c2.empty()) cis.addChunk(c2);
@@ -211,8 +225,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
VASSERT_EQ(number, expected, readWhole(is));
}
- void testStopSequenceFilteredInputStream1()
- {
+ void testStopSequenceFilteredInputStream1() {
+
testStopSequenceFISHelper <1>("1", "x", "foo", "fooxbar");
testStopSequenceFISHelper <1>("2", "x", "foo", "foox", "bar");
testStopSequenceFISHelper <1>("3", "x", "foo", "foo", "x", "bar");
@@ -231,8 +245,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testStopSequenceFISHelper <1>("13", "x", "", "", "x");
}
- void testStopSequenceFilteredInputStreamN_2()
- {
+ void testStopSequenceFilteredInputStreamN_2() {
+
testStopSequenceFISHelper <2>("1", "xy", "foo", "fooxybar");
testStopSequenceFISHelper <2>("2", "xy", "foo", "foox", "ybar");
testStopSequenceFISHelper <2>("3", "xy", "foo", "foox", "y", "bar");
@@ -255,8 +269,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testStopSequenceFISHelper <2>("17", "xy", "", "x", "y");
}
- void testStopSequenceFilteredInputStreamN_3()
- {
+ void testStopSequenceFilteredInputStreamN_3() {
+
testStopSequenceFISHelper <3>("1", "xyz", "foo", "fooxyzbar");
testStopSequenceFISHelper <3>("2", "xyz", "foo", "foox", "yzbar");
testStopSequenceFISHelper <3>("3", "xyz", "foo", "foox", "y", "zbar");
@@ -289,8 +303,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
// LFToCRLFFilteredOutputStream
- void testLFToCRLFFilteredOutputStream_Global()
- {
+ void testLFToCRLFFilteredOutputStream_Global() {
+
typedef vmime::utility::LFToCRLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "ABC\r\nDEF", "ABC\nDEF");
@@ -306,8 +320,8 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
testFilteredOutputStreamHelper<FILTER>("11", "\r\n\r\n\r\n\r\n", "\n\n\n\r\n");
}
- void testLFToCRLFFilteredOutputStream_Edge()
- {
+ void testLFToCRLFFilteredOutputStream_Edge() {
+
typedef vmime::utility::LFToCRLFFilteredOutputStream FILTER;
testFilteredOutputStreamHelper<FILTER>("1", "\r\n\r\n", "\r", "\r");
@@ -325,4 +339,3 @@ VMIME_TEST_SUITE_BEGIN(filteredStreamTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamByteArrayAdapterTest.cpp b/tests/utility/outputStreamByteArrayAdapterTest.cpp
index b14d0a39..07a0f4b9 100644
--- a/tests/utility/outputStreamByteArrayAdapterTest.cpp
+++ b/tests/utility/outputStreamByteArrayAdapterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -35,8 +35,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::byteArray bytes;
vmime::utility::outputStreamByteArrayAdapter stream(bytes);
@@ -50,8 +50,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
VASSERT_EQ("Write 2", 0, memcmp("some datamore data", &bytes[0], 18));
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
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";
@@ -65,8 +65,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, &bytes[0], sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::byteArray bytes;
vmime::utility::outputStreamByteArrayAdapter stream(bytes);
@@ -80,4 +80,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamByteArrayAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamSocketAdapterTest.cpp b/tests/utility/outputStreamSocketAdapterTest.cpp
index 4920a75c..a869ed74 100644
--- a/tests/utility/outputStreamSocketAdapterTest.cpp
+++ b/tests/utility/outputStreamSocketAdapterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -35,8 +35,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
@@ -49,8 +49,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
VASSERT_EQ("Write", "some data", buffer);
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
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";
@@ -67,8 +67,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, buffer.data(), sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
@@ -85,4 +85,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/outputStreamStringAdapterTest.cpp b/tests/utility/outputStreamStringAdapterTest.cpp
index 1cd3b3a0..3de8f8b8 100644
--- a/tests/utility/outputStreamStringAdapterTest.cpp
+++ b/tests/utility/outputStreamStringAdapterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -35,8 +35,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
VMIME_TEST_LIST_END
- void testWrite()
- {
+ void testWrite() {
+
vmime::string str("initial data");
vmime::utility::outputStreamStringAdapter stream(str);
@@ -52,8 +52,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
VASSERT_EQ("Write 2 data", "initial dataadditional datamore data", str);
}
- void testWriteBinary()
- {
+ void testWriteBinary() {
+
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";
@@ -67,8 +67,8 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
VASSERT_EQ("Write", 0, memcmp(binaryData, str.data(), sizeof(binaryData)));
}
- void testWriteCRLF()
- {
+ void testWriteCRLF() {
+
vmime::string str;
vmime::utility::outputStreamStringAdapter stream(str);
@@ -82,4 +82,3 @@ VMIME_TEST_SUITE_BEGIN(outputStreamStringAdapterTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/parserInputStreamAdapterTest.cpp b/tests/utility/parserInputStreamAdapterTest.cpp
index 0fd4f4e8..4bc310c9 100644
--- a/tests/utility/parserInputStreamAdapterTest.cpp
+++ b/tests/utility/parserInputStreamAdapterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -33,8 +33,8 @@ VMIME_TEST_SUITE_BEGIN(parserInputStreamAdapterTest)
VMIME_TEST_LIST_END
- void testEndlessLoopBufferSize()
- {
+ void testEndlessLoopBufferSize() {
+
static const unsigned int BUFFER_SIZE = 4096; // same as in parserInputStreamAdapter::findNext()
vmime::string str(BUFFER_SIZE, 'X');
diff --git a/tests/utility/pathTest.cpp b/tests/utility/pathTest.cpp
index ef1b773d..e6227f3a 100644
--- a/tests/utility/pathTest.cpp
+++ b/tests/utility/pathTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -64,14 +64,14 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
typedef vmime::utility::path::component comp;
- void testConstruct1()
- {
+ void testConstruct1() {
+
VASSERT_EQ("1", true, path().isEmpty());
VASSERT_EQ("2", 0, path().getSize());
}
- void testConstruct2()
- {
+ void testConstruct2() {
+
path p(comp("foo"));
VASSERT_EQ("1", false, p.isEmpty());
@@ -79,8 +79,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer());
}
- void testAppendComponent()
- {
+ void testAppendComponent() {
+
path p;
VASSERT_EQ("1", 0, p.getSize());
@@ -92,8 +92,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", c.getBuffer(), p.getComponentAt(0).getBuffer());
}
- void testConstruct3()
- {
+ void testConstruct3() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -105,8 +105,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "bar", p2.getComponentAt(1).getBuffer());
}
- void testConstruct4()
- {
+ void testConstruct4() {
+
// Same as path::path(const component&)
path p("foo");
@@ -115,8 +115,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer());
}
- void testOperatorDiv1()
- {
+ void testOperatorDiv1() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -132,8 +132,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer());
}
- void testOperatorDiv2()
- {
+ void testOperatorDiv2() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -148,8 +148,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer());
}
- void testOperatorDivEqual1()
- {
+ void testOperatorDivEqual1() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -166,8 +166,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer());
}
- void testOperatorDivEqual2()
- {
+ void testOperatorDivEqual2() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -183,8 +183,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer());
}
- void testGetParent()
- {
+ void testGetParent() {
+
path p1;
path p1p = p1.getParent();
@@ -200,8 +200,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", p2.getComponentAt(0).getBuffer(), p2p.getComponentAt(0).getBuffer());
}
- void testComparison()
- {
+ void testComparison() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -224,8 +224,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("5", true, p3.getParent() == p1);
}
- void testGetLastComponent()
- {
+ void testGetLastComponent() {
+
path p1;
p1.appendComponent(comp("foo"));
p1.appendComponent(comp("bar"));
@@ -236,8 +236,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("3", "foo", p1.getParent().getParent().getLastComponent().getBuffer());
}
- void testIsDirectParentOf()
- {
+ void testIsDirectParentOf() {
+
path p1;
p1.appendComponent(comp("foo"));
@@ -256,8 +256,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", false, p2.isDirectParentOf(p1));
}
- void testIsParentOf()
- {
+ void testIsParentOf() {
+
path p1;
p1.appendComponent(comp("foo"));
@@ -276,8 +276,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("4", false, p2.isParentOf(p1));
}
- void testIsParentOf_EquivalentCharset()
- {
+ void testIsParentOf_EquivalentCharset() {
+
path p1;
p1.appendComponent(comp("foo", "us-ascii"));
@@ -289,8 +289,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("1", true, p1.isParentOf(p2));
}
- void testRenameParent()
- {
+ void testRenameParent() {
+
path p1;
p1.appendComponent(comp("a"));
p1.appendComponent(comp("b"));
@@ -317,8 +317,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("6", "d", p.getComponentAt(4).getBuffer());
}
- void testFromString()
- {
+ void testFromString() {
+
path p = path::fromString("ab/cde/f", "/", vmime::charset("my-charset"));
VASSERT_EQ("count", 3, p.getSize());
@@ -330,8 +330,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
}
- void testFromString_IgnoreLeadingOrTrailingSep()
- {
+ void testFromString_IgnoreLeadingOrTrailingSep() {
+
path p = path::fromString("//ab/cde/f////", "/", vmime::charset("my-charset"));
VASSERT_EQ("count", 3, p.getSize());
@@ -343,8 +343,8 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VASSERT_EQ("charset3", "my-charset", p.getComponentAt(2).getCharset().getName());
}
- void testToString()
- {
+ void testToString() {
+
path p;
p.appendComponent(comp("ab"));
p.appendComponent(comp("cde"));
@@ -354,4 +354,3 @@ VMIME_TEST_SUITE_BEGIN(utilityPathTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/seekableInputStreamRegionAdapterTest.cpp b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
index e703051b..b099cd77 100644
--- a/tests/utility/seekableInputStreamRegionAdapterTest.cpp
+++ b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -43,9 +43,10 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VMIME_TEST_LIST_END
- vmime::shared_ptr <seekableInputStreamRegionAdapter> createStream
- (vmime::shared_ptr <seekableInputStream>* underlyingStream = NULL)
- {
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> createStream(
+ vmime::shared_ptr <seekableInputStream>* underlyingStream = NULL
+ ) {
+
vmime::string buffer("THIS IS A TEST BUFFER");
vmime::shared_ptr <seekableInputStream> strStream =
@@ -54,22 +55,23 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
vmime::shared_ptr <seekableInputStreamRegionAdapter> rgnStream =
vmime::make_shared <seekableInputStreamRegionAdapter>(strStream, 10, 11);
- if (underlyingStream)
+ if (underlyingStream) {
*underlyingStream = strStream;
+ }
return rgnStream;
}
- void testInitialPosition()
- {
+ void testInitialPosition() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
VASSERT_EQ("Pos", 0, stream->getPosition());
VASSERT_FALSE("EOF", stream->eof());
}
- void testSeekAndGetPosition()
- {
+ void testSeekAndGetPosition() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
@@ -83,8 +85,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_TRUE("EOF 2", stream->eof());
}
- void testRead()
- {
+ void testRead() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
@@ -96,12 +98,11 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Pos", 11, stream->getPosition());
VASSERT_EQ("Read", 6, read);
VASSERT_TRUE("EOF", stream->eof());
- VASSERT_EQ("Buffer", "BUFFER",
- vmime::utility::stringUtils::makeStringFromBytes(buffer, 6));
+ VASSERT_EQ("Buffer", "BUFFER", vmime::utility::stringUtils::makeStringFromBytes(buffer, 6));
}
- void testSkip()
- {
+ void testSkip() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(5);
@@ -116,8 +117,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Pos 2", 8, stream->getPosition());
VASSERT_EQ("Read", 3, read);
VASSERT_FALSE("EOF 2", stream->eof());
- VASSERT_EQ("Buffer", "BUF",
- vmime::utility::stringUtils::makeStringFromBytes(buffer, 3));
+ VASSERT_EQ("Buffer", "BUF", vmime::utility::stringUtils::makeStringFromBytes(buffer, 3));
stream->skip(50);
@@ -125,8 +125,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_TRUE("EOF 3", stream->eof());
}
- void testReset()
- {
+ void testReset() {
+
vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(100);
@@ -136,8 +136,8 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_FALSE("EOF", stream->eof());
}
- void testOwnPosition()
- {
+ void testOwnPosition() {
+
// seekableInputStreamRegionAdapter should keep track of its own position
// in the underlying stream, and not be affected by possible seek/read
// operations on it...
@@ -156,10 +156,17 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_EQ("Read 2", 6, stream->read(buffer2, 6));
- VASSERT_EQ("Buffer 1", "THIS IS",
- vmime::utility::stringUtils::makeStringFromBytes(buffer1, 7));
- VASSERT_EQ("Buffer 2", "BUFFER",
- vmime::utility::stringUtils::makeStringFromBytes(buffer2, 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 d6513681..89b96568 100644
--- a/tests/utility/stringProxyTest.cpp
+++ b/tests/utility/stringProxyTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -41,8 +41,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VMIME_TEST_LIST_END
- void testConstruct()
- {
+ void testConstruct() {
+
vmime::utility::stringProxy s;
VASSERT_EQ("1", static_cast <vmime::size_t>(0), s.length());
@@ -50,8 +50,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
- void testConstruct2()
- {
+ void testConstruct2() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str);
@@ -78,8 +78,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("13", 't', *(s3.it_begin() + 3));
}
- void testDetach()
- {
+ void testDetach() {
+
vmime::utility::stringProxy s;
s = "foo";
@@ -90,8 +90,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("3", static_cast <vmime::size_t>(0), s.end());
}
- void testSet()
- {
+ void testSet() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1;
@@ -121,8 +121,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("13", 't', *(s3.it_begin() + 3));
}
- void testExtract()
- {
+ void testExtract() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -144,8 +144,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("2", str, oss2.str());
}
- void testOperatorLTLT1()
- {
+ void testOperatorLTLT1() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -163,8 +163,8 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
VASSERT_EQ("2", str, oss2.str());
}
- void testOperatorLTLT2()
- {
+ void testOperatorLTLT2() {
+
vmime::string str("This is a test string.");
vmime::utility::stringProxy s1(str, 10, 14);
@@ -187,4 +187,3 @@ VMIME_TEST_SUITE_BEGIN(stringProxyTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp
index d86bbda0..6c2e18fb 100644
--- a/tests/utility/stringUtilsTest.cpp
+++ b/tests/utility/stringUtilsTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -52,8 +52,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
typedef vmime::utility::stringUtils stringUtils;
- void testMakeStringFromBytes()
- {
+ void testMakeStringFromBytes() {
+
vmime::byte_t bytes[] = { 0x12, 0x34, 0x56, 0x78 };
vmime::string str = vmime::utility::stringUtils::makeStringFromBytes(bytes, 3);
@@ -63,8 +63,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("byte3", '\x56', str[2]);
}
- void testAppendBytesToString()
- {
+ void testAppendBytesToString() {
+
vmime::byte_t bytes[] = { 0x42, 0x56, 0x12, 0x00, 'f', 'o', 'o' };
vmime::string str = "test";
@@ -84,41 +84,52 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("byte11", 'o', str[10]);
}
- void testIsStringEqualNoCase1()
- {
+ void testIsStringEqualNoCase1() {
+
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3));
VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3));
VASSERT_EQ("3", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3));
VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3));
+
+ VASSERT_EQ("5", false, stringUtils::isStringEqualNoCase(vmime::string("foO"), "bar", 3));
+ VASSERT_EQ("6", false, stringUtils::isStringEqualNoCase(vmime::string("foOO"), "barO", 4));
+ VASSERT_EQ("7", false, stringUtils::isStringEqualNoCase(vmime::string("foOO"), "ba", 2));
+
+ VASSERT_EQ("8", true, stringUtils::isStringEqualNoCase(vmime::string("FOoooo"), "foo", 3));
}
- void testIsStringEqualNoCase2()
- {
+ void testIsStringEqualNoCase2() {
+
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo")));
VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo")));
VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo")));
+
+ VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("bar")));
+ VASSERT_EQ("5", false, stringUtils::isStringEqualNoCase(vmime::string("foOO"), vmime::string("barO")));
}
- void testIsStringEqualNoCase3()
- {
+ void testIsStringEqualNoCase3() {
+
vmime::string str1("FooBar");
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6));
VASSERT_EQ("2", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6));
VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3));
VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6));
+ VASSERT_EQ("5", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "bar", 3));
+ VASSERT_EQ("6", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 6, "barbar", 6));
}
- void testToLower()
- {
+ void testToLower() {
+
VASSERT_EQ("1", "foo", stringUtils::toLower("FOO"));
VASSERT_EQ("2", "foo", stringUtils::toLower("foO"));
VASSERT_EQ("3", "foo", stringUtils::toLower("foo"));
}
- void testTrim()
- {
+ void testTrim() {
+
VASSERT_EQ("1", "foo", stringUtils::trim(" foo"));
VASSERT_EQ("2", "foo", stringUtils::trim("\t\tfoo"));
VASSERT_EQ("3", "foo", stringUtils::trim(" \t \tfoo"));
@@ -136,35 +147,47 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("13", "foo", stringUtils::trim("\r \tfoo \n\t"));
}
- void testCountASCIIChars()
- {
+ void testCountASCIIChars() {
+
vmime::string str1("foo");
- VASSERT_EQ("1", static_cast <vmime::size_t>(3),
- stringUtils::countASCIIchars(str1.begin(), str1.end()));
+ 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::size_t>(3 + 1),
- stringUtils::countASCIIchars(str2.begin(), str2.end()));
+ 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::size_t>(4),
- stringUtils::countASCIIchars(str3.begin(), str3.end()));
+ 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::size_t>(3),
- stringUtils::countASCIIchars(str4.begin(), str4.end()));
+ VASSERT_EQ(
+ "4",
+ static_cast <vmime::size_t>(3),
+ stringUtils::countASCIIchars(str4.begin(), str4.end())
+ );
}
- void testUnquote()
- {
+ void testUnquote() {
+
VASSERT_EQ("1", "quoted", stringUtils::unquote("\"quoted\"")); // "quoted"
VASSERT_EQ("2", "\"not quoted", stringUtils::unquote("\"not quoted")); // "not quoted
VASSERT_EQ("3", "not quoted\"", stringUtils::unquote("not quoted\"")); // not quoted"
VASSERT_EQ("4", "quoted with \"escape\"", stringUtils::unquote("\"quoted with \\\"escape\\\"\"")); // "quoted with \"escape\""
}
- void testIsValidHostname()
- {
+ void testIsValidHostname() {
+
VASSERT_TRUE ("1", stringUtils::isValidHostname("localhost"));
VASSERT_TRUE ("2", stringUtils::isValidHostname("localhost.localdomain"));
VASSERT_TRUE ("3", stringUtils::isValidHostname("example.com"));
@@ -176,8 +199,8 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_FALSE("9", stringUtils::isValidHostname("-example.com"));
}
- void testIsValidFQDN()
- {
+ void testIsValidFQDN() {
+
VASSERT_FALSE("1", stringUtils::isValidFQDN("localhost"));
VASSERT_FALSE("2", stringUtils::isValidFQDN("localhost.localdomain"));
VASSERT_FALSE("3", stringUtils::isValidFQDN("example.com"));
@@ -189,4 +212,3 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
}
VMIME_TEST_SUITE_END
-
diff --git a/tests/utility/urlTest.cpp b/tests/utility/urlTest.cpp
index 85991511..36820a68 100644
--- a/tests/utility/urlTest.cpp
+++ b/tests/utility/urlTest.cpp
@@ -1,6 +1,6 @@
//
// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
+// Copyright (C) 2002 Vincent Richard <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -44,14 +44,14 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VMIME_TEST_LIST_END
- static bool parseHelper(vmime::utility::url& u, const vmime::string& str)
- {
- try
- {
+ static bool parseHelper(vmime::utility::url& u, const vmime::string& str) {
+
+ try {
+
u = vmime::utility::url(str);
- }
- catch (vmime::exceptions::malformed_url)
- {
+
+ } catch (vmime::exceptions::malformed_url) {
+
return false;
}
@@ -59,8 +59,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
- void testParse1()
- {
+ void testParse1() {
+
// Test some valid constructions
vmime::utility::url u1("", "");
@@ -123,8 +123,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("6.7", "/path/file", u4.getPath());
}
- void testParse2()
- {
+ void testParse2() {
+
// Now, test some ill-formed URLs
// -- missing protocol
@@ -144,8 +144,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("4", false, parseHelper(u4, "protohost/path"));
}
- void testParse3()
- {
+ void testParse3() {
+
// Test decoding
vmime::utility::url u1("", "");
@@ -158,8 +158,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath());
}
- void testParse4()
- {
+ void testParse4() {
+
// Test parameters
vmime::utility::url u1("", "");
@@ -191,8 +191,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
// '@' symbol in the username part
- void testParse5()
- {
+ void testParse5() {
+
vmime::utility::url u1("", "");
VASSERT_EQ("1", true, parseHelper(u1, "imap://[email protected]:[email protected]"));
@@ -201,42 +201,54 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("4", "myserver.com", u1.getHost());
}
- void testGenerate()
- {
+ void testGenerate() {
+
vmime::utility::url u1("proto", "host", 12345, "path", "user", "password");
- VASSERT_EQ("1", "proto://user:password@host:12345/path",
- static_cast <vmime::string>(u1));
+ VASSERT_EQ(
+ "1",
+ "proto://user:password@host:12345/path",
+ static_cast <vmime::string>(u1)
+ );
vmime::utility::url u2("proto", "host");
VASSERT_EQ("2", "proto://host", static_cast <vmime::string>(u2));
vmime::utility::url u3("proto", "host");
u3.getParams()["p1"] = "v1";
- VASSERT_EQ("3.1", "proto://host/?p1=v1",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.1",
+ "proto://host/?p1=v1",
+ static_cast <vmime::string>(u3)
+ );
u3.getParams()["p2"] = "v2";
- VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.2",
+ "proto://host/?p1=v1&p2=v2",
+ static_cast <vmime::string>(u3)
+ );
// Test special characters
u3.getParams().clear();
u3.getParams()["&"] = "=";
- VASSERT_EQ("3.3", "proto://host/?%26=%3D",
- static_cast <vmime::string>(u3));
+ VASSERT_EQ(
+ "3.3",
+ "proto://host/?%26=%3D",
+ static_cast <vmime::string>(u3)
+ );
}
- void testUtilsEncode()
- {
+ void testUtilsEncode() {
+
VASSERT_EQ("1", "%01", vmime::utility::urlUtils::encode("\x01"));
VASSERT_EQ("2", "%20", vmime::utility::urlUtils::encode(" "));
VASSERT_EQ("3", "%FF", vmime::utility::urlUtils::encode("\xff"));
VASSERT_EQ("4", "a", vmime::utility::urlUtils::encode("a"));
}
- void testUtilsDecode()
- {
- for (int i = 0 ; i < 255 ; ++i)
- {
+ void testUtilsDecode() {
+
+ for (int i = 0 ; i < 255 ; ++i) {
+
std::ostringstream ossTest;
ossTest << "%" << "0123456789ABCDEF"[i / 16]
<< "0123456789ABCDEF"[i % 16];
@@ -247,22 +259,25 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
vmime::string res;
res += static_cast <unsigned char>(i);
- VASSERT_EQ(ossNum.str(), res,
- vmime::utility::urlUtils::decode(ossTest.str()));
+ VASSERT_EQ(
+ ossNum.str(),
+ res,
+ vmime::utility::urlUtils::decode(ossTest.str())
+ );
}
}
- void testUtilsDecodeSpecialCases()
- {
+ void testUtilsDecodeSpecialCases() {
+
// Bug #1656547: segfault with '%' at the end of the string
VASSERT_EQ("1.1", "sadfsda%", vmime::utility::urlUtils::decode("sadfsda%"));
VASSERT_EQ("1.2", "sadfsda\x05", vmime::utility::urlUtils::decode("sadfsda%5"));
VASSERT_EQ("1.3", "sadfsda\x42", vmime::utility::urlUtils::decode("sadfsda%42"));
}
- void testUtilsEncodeReservedChars()
- {
+ void testUtilsEncodeReservedChars() {
+
VASSERT_EQ("1", "%24", vmime::utility::urlUtils::encode("$"));
VASSERT_EQ("2", "%26", vmime::utility::urlUtils::encode("&"));
VASSERT_EQ("3", "%2B", vmime::utility::urlUtils::encode("+"));
@@ -275,8 +290,8 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
VASSERT_EQ("10", "%40", vmime::utility::urlUtils::encode("@"));
}
- void testUtilsEncodeUnsafeChars()
- {
+ void testUtilsEncodeUnsafeChars() {
+
VASSERT_EQ("1", "%20", vmime::utility::urlUtils::encode(" "));
VASSERT_EQ("2", "%22", vmime::utility::urlUtils::encode("\""));
VASSERT_EQ("3", "%3C", vmime::utility::urlUtils::encode("<"));
@@ -295,4 +310,3 @@ VMIME_TEST_SUITE_BEGIN(urlTest)
}
VMIME_TEST_SUITE_END
-