summaryrefslogtreecommitdiff
path: root/unittests/Utility/VASprintfTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
commitef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch)
tree27916256fdeeb57d10d2f3d6948be5d71a703215 /unittests/Utility/VASprintfTest.cpp
parent76e0736e7fcfeb179779e49c05604464b1ccd704 (diff)
Notes
Diffstat (limited to 'unittests/Utility/VASprintfTest.cpp')
-rw-r--r--unittests/Utility/VASprintfTest.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/unittests/Utility/VASprintfTest.cpp b/unittests/Utility/VASprintfTest.cpp
index 0b440942eb5a..cb5b2533688e 100644
--- a/unittests/Utility/VASprintfTest.cpp
+++ b/unittests/Utility/VASprintfTest.cpp
@@ -14,6 +14,12 @@
#include <locale.h>
+#if defined (_WIN32)
+#define TEST_ENCODING ".932" // On Windows, test codepage 932
+#else
+#define TEST_ENCODING "C" // ...otherwise, any widely available uni-byte LC
+#endif
+
using namespace lldb_private;
using namespace llvm;
@@ -46,7 +52,8 @@ TEST(VASprintfTest, EncodingError) {
// Save the current locale first.
std::string Current(::setlocale(LC_ALL, nullptr));
- setlocale(LC_ALL, ".932");
+ // Ensure tested locale is successfully set
+ ASSERT_TRUE(setlocale(LC_ALL, TEST_ENCODING));
wchar_t Invalid[2];
Invalid[0] = 0x100;
@@ -55,5 +62,6 @@ TEST(VASprintfTest, EncodingError) {
EXPECT_FALSE(Sprintf(Buffer, "%ls", Invalid));
EXPECT_EQ("<Encoding error>", Buffer);
- setlocale(LC_ALL, Current.c_str());
+ // Ensure we've restored the original locale once tested
+ ASSERT_TRUE(setlocale(LC_ALL, Current.c_str()));
}