aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utility/encoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/utility/encoder/b64EncoderTest.cpp8
-rw-r--r--tests/utility/encoder/encoderTestUtils.hpp22
-rw-r--r--tests/utility/encoder/qpEncoderTest.cpp8
3 files changed, 30 insertions, 8 deletions
diff --git a/tests/utility/encoder/b64EncoderTest.cpp b/tests/utility/encoder/b64EncoderTest.cpp
index 589afaba..fa6fd766 100644
--- a/tests/utility/encoder/b64EncoderTest.cpp
+++ b/tests/utility/encoder/b64EncoderTest.cpp
@@ -138,6 +138,14 @@ VMIME_TEST_SUITE_BEGIN(b64EncoderTest)
encode("base64",
encode("base64",
encode("base64", decoded)))))))));
+
+ VASSERT(oss.str() + "encoded size",
+ getEncoder("base64")->getEncodedSize(decoded.length())
+ >= encode("base64", decoded).length());
+
+ VASSERT(oss.str() + "decoded size",
+ getEncoder("base64")->getDecodedSize(encoded.length())
+ >= decode("base64", encoded).length());
}
}
diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp
index dd2484ed..0eb93871 100644
--- a/tests/utility/encoder/encoderTestUtils.hpp
+++ b/tests/utility/encoder/encoderTestUtils.hpp
@@ -22,9 +22,9 @@
//
-// 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())
+// Helper function to obtain an encoder given its name
+static vmime::ref <vmime::utility::encoder::encoder> getEncoder(const vmime::string& name,
+ int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
{
vmime::ref <vmime::utility::encoder::encoder> enc =
vmime::utility::encoder::encoderFactory::getInstance()->create(name);
@@ -34,6 +34,16 @@ static const vmime::string encode(const vmime::string& name, const vmime::string
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())
+{
+ vmime::ref <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength, props);
+
vmime::utility::inputStreamStringAdapter vin(in);
std::ostringstream out;
@@ -48,11 +58,7 @@ 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)
{
- vmime::ref <vmime::utility::encoder::encoder> enc =
- vmime::utility::encoder::encoderFactory::getInstance()->create(name);
-
- if (maxLineLength != 0)
- enc->getProperties()["maxlinelength"] = maxLineLength;
+ vmime::ref <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 790c5fb3..50183488 100644
--- a/tests/utility/encoder/qpEncoderTest.cpp
+++ b/tests/utility/encoder/qpEncoderTest.cpp
@@ -134,6 +134,14 @@ VMIME_TEST_SUITE_BEGIN(qpEncoderTest)
encode("quoted-printable",
encode("quoted-printable",
encode("quoted-printable", decoded)))))))));
+
+ VASSERT(oss.str() + "encoded size",
+ getEncoder("quoted-printable")->getEncodedSize(decoded.length())
+ >= encode("quoted-printable", decoded).length());
+
+ VASSERT(oss.str() + "decoded size",
+ getEncoder("quoted-printable")->getDecodedSize(encoded.length())
+ >= decode("quoted-printable", encoded).length());
}
}