diff options
author | Vincent Richard <[email protected]> | 2014-01-15 23:27:51 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2014-01-15 23:27:51 +0000 |
commit | ef892af6556724b6d04dfb1767dce132f9d97257 (patch) | |
tree | dee732540e681ad58c4f6835c2d960238bf20b26 /tests/parser/emailAddressTest.cpp | |
parent | Avoid calling charset::convert() if no conversion is needed. (diff) | |
download | vmime-ef892af6556724b6d04dfb1767dce132f9d97257.tar.gz vmime-ef892af6556724b6d04dfb1767dce132f9d97257.zip |
Do not make calls to setlocale() in a library. Use default user locale in tests and examples.
Diffstat (limited to 'tests/parser/emailAddressTest.cpp')
-rw-r--r-- | tests/parser/emailAddressTest.cpp | 24 |
1 files changed, 24 insertions, 0 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"); |