Skip to content

Commit b7578f9

Browse files
committed
[RGT] Tweak test so assertion is always executed
Any given Windows system will have only one "system" encoding for UTF-16 (BE or LE), so the assert for the other one would always show up as rotten. Use a common assertion for both paths to avoid this.
1 parent e413b86 commit b7578f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/unittests/Support/ProgramTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,15 @@ TEST(ProgramTest, TestWriteWithSystemEncoding) {
320320
#if defined(_WIN32)
321321
char buf[18];
322322
ASSERT_EQ(::read(fd, buf, 18), 18);
323+
const char *utf16_text;
323324
if (strncmp(buf, "\xfe\xff", 2) == 0) { // UTF16-BE
324-
ASSERT_EQ(strncmp(&buf[2], utf16be_text, 16), 0);
325+
utf16_text = utf16be_text;
325326
} else if (strncmp(buf, "\xff\xfe", 2) == 0) { // UTF16-LE
326-
ASSERT_EQ(strncmp(&buf[2], utf16le_text, 16), 0);
327+
utf16_text = utf16le_text;
327328
} else {
328329
FAIL() << "Invalid BOM in UTF-16 file";
329330
}
331+
ASSERT_EQ(strncmp(&buf[2], utf16_text, 16), 0);
330332
#else
331333
char buf[10];
332334
ASSERT_EQ(::read(fd, buf, 10), 10);

0 commit comments

Comments
 (0)