aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser/textTest.cpp
diff options
context:
space:
mode:
authorJan Engelhardt <[email protected]>2024-05-21 13:47:05 +0000
committerGitHub <[email protected]>2024-05-21 13:47:05 +0000
commitb447adbe373d3940d2023d8e7a6ec21c7bfb8a48 (patch)
tree5c8092e7215d83400ec5ad3a377f3da9db7678c0 /tests/parser/textTest.cpp
parentvmime: avoid changing SEVEN_BIT when encoding::decideImpl sees U+007F (#303) (diff)
downloadvmime-b447adbe373d3940d2023d8e7a6ec21c7bfb8a48.tar.gz
vmime-b447adbe373d3940d2023d8e7a6ec21c7bfb8a48.zip
Fixes/comments for guessBestEncoding (#304)
* tests: add case for getRecommendedEncoding * vmime: avoid integer multiply wraparound in wordEncoder::guessBestEncoding If the input string is 42949673 characters long or larger, there will be integer overflow on 32-bit platforms when multiplying by 100. Switch that one computation to floating point. * vmime: update comment in wordEncoder::guessBestEncoding
Diffstat (limited to '')
-rw-r--r--tests/parser/textTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp
index e9ddc262..f5111e79 100644
--- a/tests/parser/textTest.cpp
+++ b/tests/parser/textTest.cpp
@@ -32,6 +32,7 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VMIME_TEST_LIST_BEGIN
VMIME_TEST(testConstructors)
VMIME_TEST(testCopy)
+ VMIME_TEST(testRecommendedEncoding)
VMIME_TEST(testNewFromString)
VMIME_TEST(testDisplayForm)
VMIME_TEST(testParse)
@@ -155,6 +156,17 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT("copyFrom", t1 == t2);
}
+ void testRecommendedEncoding() {
+
+ vmime::encoding enc;
+ VASSERT_TRUE("1.1", vmime::charset("iso8859-1").getRecommendedEncoding(enc));
+ VASSERT_TRUE("1.2", enc.getName() == vmime::encodingTypes::QUOTED_PRINTABLE);
+ VASSERT_TRUE("1.2", vmime::charset("iso8859-2").getRecommendedEncoding(enc));
+ VASSERT_TRUE("1.3", enc.getName() == vmime::encodingTypes::QUOTED_PRINTABLE);
+ VASSERT_FALSE("1.3", vmime::charset(vmime::charsets::UTF_8).getRecommendedEncoding(enc));
+
+ }
+
void testNewFromString() {
vmime::string s1 = "only ASCII characters";