[llvm] b7578f9 - [RGT] Tweak test so assertion is always executed
Paul Robinson via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 9 08:11:03 PDT 2021
Author: Paul Robinson
Date: 2021-04-09T08:10:45-07:00
New Revision: b7578f9d5a465ae1c061ccfbe3cf2a5265785f87
URL: https://github.com/llvm/llvm-project/commit/b7578f9d5a465ae1c061ccfbe3cf2a5265785f87
DIFF: https://github.com/llvm/llvm-project/commit/b7578f9d5a465ae1c061ccfbe3cf2a5265785f87.diff
LOG: [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.
Added:
Modified:
llvm/unittests/Support/ProgramTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/ProgramTest.cpp b/llvm/unittests/Support/ProgramTest.cpp
index 84a5d3f64cfe6..98eb81c0abf58 100644
--- a/llvm/unittests/Support/ProgramTest.cpp
+++ b/llvm/unittests/Support/ProgramTest.cpp
@@ -320,13 +320,15 @@ TEST(ProgramTest, TestWriteWithSystemEncoding) {
#if defined(_WIN32)
char buf[18];
ASSERT_EQ(::read(fd, buf, 18), 18);
+ const char *utf16_text;
if (strncmp(buf, "\xfe\xff", 2) == 0) { // UTF16-BE
- ASSERT_EQ(strncmp(&buf[2], utf16be_text, 16), 0);
+ utf16_text = utf16be_text;
} else if (strncmp(buf, "\xff\xfe", 2) == 0) { // UTF16-LE
- ASSERT_EQ(strncmp(&buf[2], utf16le_text, 16), 0);
+ utf16_text = utf16le_text;
} else {
FAIL() << "Invalid BOM in UTF-16 file";
}
+ ASSERT_EQ(strncmp(&buf[2], utf16_text, 16), 0);
#else
char buf[10];
ASSERT_EQ(::read(fd, buf, 10), 10);
More information about the llvm-commits
mailing list