mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Reland "[Support][unittests] Enforce alignment in ConvertUTFTest"
This relands commit 53b3873cf428fd78f1d92504cc20adf11181ead7. The failure of `ConvertUTFTest.UTF16WrappersForConvertUTF16ToUTF8String` detected the first time is fixed. Differential Revision: https://reviews.llvm.org/D88824
This commit is contained in:
parent
fdd7b4d261
commit
3282b2f497
@ -97,6 +97,8 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
|
|||||||
const UTF16 *Src = reinterpret_cast<const UTF16 *>(SrcBytes.begin());
|
const UTF16 *Src = reinterpret_cast<const UTF16 *>(SrcBytes.begin());
|
||||||
const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(SrcBytes.end());
|
const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(SrcBytes.end());
|
||||||
|
|
||||||
|
assert((uintptr_t)Src % sizeof(UTF16) == 0);
|
||||||
|
|
||||||
// Byteswap if necessary.
|
// Byteswap if necessary.
|
||||||
std::vector<UTF16> ByteSwapped;
|
std::vector<UTF16> ByteSwapped;
|
||||||
if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
|
if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
|
||||||
|
@ -16,7 +16,7 @@ using namespace llvm;
|
|||||||
|
|
||||||
TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
|
TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
|
||||||
// Src is the look of disapproval.
|
// Src is the look of disapproval.
|
||||||
static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
|
alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
|
||||||
ArrayRef<char> Ref(Src, sizeof(Src) - 1);
|
ArrayRef<char> Ref(Src, sizeof(Src) - 1);
|
||||||
std::string Result;
|
std::string Result;
|
||||||
bool Success = convertUTF16ToUTF8String(Ref, Result);
|
bool Success = convertUTF16ToUTF8String(Ref, Result);
|
||||||
@ -27,7 +27,7 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
|
|||||||
|
|
||||||
TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
|
TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
|
||||||
// Src is the look of disapproval.
|
// Src is the look of disapproval.
|
||||||
static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
|
alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
|
||||||
ArrayRef<char> Ref(Src, sizeof(Src) - 1);
|
ArrayRef<char> Ref(Src, sizeof(Src) - 1);
|
||||||
std::string Result;
|
std::string Result;
|
||||||
bool Success = convertUTF16ToUTF8String(Ref, Result);
|
bool Success = convertUTF16ToUTF8String(Ref, Result);
|
||||||
@ -80,7 +80,7 @@ TEST(ConvertUTFTest, HasUTF16BOM) {
|
|||||||
|
|
||||||
TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
|
TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
|
||||||
// Src is the look of disapproval.
|
// Src is the look of disapproval.
|
||||||
static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
|
alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
|
||||||
ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4);
|
ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4);
|
||||||
std::string Result;
|
std::string Result;
|
||||||
bool Success = convertUTF16ToUTF8String(SrcRef, Result);
|
bool Success = convertUTF16ToUTF8String(SrcRef, Result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user