forked from OSchip/llvm-project
Fix VASprintfTest.cpp for Darwin, add checks
Summary: The EncodingError test ensures that trying to encode a multibyte wchar with a given codepage fails. If setlocale() fails, the encoding is performed using the current locale, which may or may not fail. This patch asserts that both setlocale() operations are successful, as well as falling back to a widely available unibyte encoding for non-Windows systems. <rdar://problem/33782806> Reviewers: zturner, labath, lhames Reviewed By: zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D36496 llvm-svn: 310499
This commit is contained in:
parent
7f60c991ae
commit
5706f1e6f6
|
@ -875,6 +875,7 @@
|
|||
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
|
||||
9A1E595C1EB2B141002206A5 /* SBTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1E59521EB2B0B9002206A5 /* SBTrace.cpp */; };
|
||||
9A1E595D1EB2B141002206A5 /* SBTraceOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1E59531EB2B0B9002206A5 /* SBTraceOptions.cpp */; };
|
||||
9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */; };
|
||||
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
|
||||
9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15F135E30370024DDC3 /* EmulationStateARM.cpp */; };
|
||||
9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
@ -7092,6 +7093,7 @@
|
|||
AFEC5FD81D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp in Sources */,
|
||||
23CB15401D66DA9300EDDDE1 /* TestClangASTContext.cpp in Sources */,
|
||||
23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources */,
|
||||
9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */,
|
||||
23CB15421D66DA9300EDDDE1 /* TaskPoolTest.cpp in Sources */,
|
||||
23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp in Sources */,
|
||||
9A3D43EE1F3237F900EB767C /* StreamCallbackTest.cpp in Sources */,
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue