aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/parser/emailAddressTest.cpp24
-rw-r--r--tests/parser/parameterTest.cpp24
-rw-r--r--tests/parser/textTest.cpp24
-rw-r--r--tests/utility/pathTest.cpp16
4 files changed, 87 insertions, 1 deletions
diff --git a/tests/parser/emailAddressTest.cpp b/tests/parser/emailAddressTest.cpp
index 378cc065..4916aaa9 100644
--- a/tests/parser/emailAddressTest.cpp
+++ b/tests/parser/emailAddressTest.cpp
@@ -25,6 +25,9 @@
#include "vmime/platform.hpp"
+#include <locale>
+#include <clocale>
+
VMIME_TEST_SUITE_BEGIN(emailAddressTest)
@@ -41,6 +44,27 @@ VMIME_TEST_SUITE_BEGIN(emailAddressTest)
VMIME_TEST_LIST_END
+ void setUp()
+ {
+ // Set the global C and C++ locale to the user-configured locale.
+ // The locale should use UTF-8 encoding for these tests to run successfully.
+ try
+ {
+ std::locale::global(std::locale(""));
+ }
+ catch (std::exception &)
+ {
+ std::setlocale(LC_ALL, "");
+ }
+ }
+
+ void tearDown()
+ {
+ // Restore default locale
+ std::locale::global(std::locale("C"));
+ }
+
+
void testParseASCII()
{
vmime::emailAddress eml1("local@domain");
diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp
index 3b0edebf..4f6f8677 100644
--- a/tests/parser/parameterTest.cpp
+++ b/tests/parser/parameterTest.cpp
@@ -23,6 +23,9 @@
#include "tests/testUtils.hpp"
+#include <locale>
+#include <clocale>
+
VMIME_TEST_SUITE_BEGIN(parameterTest)
@@ -62,6 +65,27 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
(p.getParameterAt(n)->getValue().getBuffer())
+ void setUp()
+ {
+ // Set the global C and C++ locale to the user-configured locale.
+ // The locale should use UTF-8 encoding for these tests to run successfully.
+ try
+ {
+ std::locale::global(std::locale(""));
+ }
+ catch (std::exception &)
+ {
+ std::setlocale(LC_ALL, "");
+ }
+ }
+
+ void tearDown()
+ {
+ // Restore default locale
+ std::locale::global(std::locale("C"));
+ }
+
+
void testParse()
{
// Simple parameter
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp
index 274687a5..f56f972d 100644
--- a/tests/parser/textTest.cpp
+++ b/tests/parser/textTest.cpp
@@ -23,6 +23,9 @@
#include "tests/testUtils.hpp"
+#include <locale>
+#include <clocale>
+
VMIME_TEST_SUITE_BEGIN(textTest)
@@ -78,6 +81,27 @@ VMIME_TEST_SUITE_BEGIN(textTest)
}
+ void setUp()
+ {
+ // Set the global C and C++ locale to the user-configured locale.
+ // The locale should use UTF-8 encoding for these tests to run successfully.
+ try
+ {
+ std::locale::global(std::locale(""));
+ }
+ catch (std::exception &)
+ {
+ std::setlocale(LC_ALL, "");
+ }
+ }
+
+ void tearDown()
+ {
+ // Restore default locale
+ std::locale::global(std::locale("C"));
+ }
+
+
void testConstructors()
{
vmime::text t1;
diff --git a/tests/utility/pathTest.cpp b/tests/utility/pathTest.cpp
index 93215586..d0c1c091 100644
--- a/tests/utility/pathTest.cpp
+++ b/tests/utility/pathTest.cpp
@@ -26,7 +26,7 @@
#include "vmime/utility/path.hpp"
-VMIME_TEST_SUITE_BEGIN(pathTest)
+VMIME_TEST_SUITE_BEGIN(utilityPathTest)
VMIME_TEST_LIST_BEGIN
VMIME_TEST(testConstruct1)
@@ -50,6 +50,7 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
VMIME_TEST(testIsDirectParentOf)
VMIME_TEST(testIsParentOf)
+ VMIME_TEST(testIsParentOf_EquivalentCharset)
VMIME_TEST(testRenameParent)
VMIME_TEST_LIST_END
@@ -271,6 +272,19 @@ VMIME_TEST_SUITE_BEGIN(pathTest)
VASSERT_EQ("4", false, p2.isParentOf(p1));
}
+ void testIsParentOf_EquivalentCharset()
+ {
+ path p1;
+ p1.appendComponent(comp("foo", "us-ascii"));
+
+ path p2;
+ p2.appendComponent(comp("foo", "utf-8"));
+ p2.appendComponent(comp("bar"));
+ p2.appendComponent(comp("baz"));
+
+ VASSERT_EQ("1", true, p1.isParentOf(p2));
+ }
+
void testRenameParent()
{
path p1;