diff options
| author | 2017-01-14 19:55:43 +0000 | |
|---|---|---|
| committer | 2017-01-14 19:55:43 +0000 | |
| commit | bd3306aecb3a15e8967143b8cdbbccf2b1b19b74 (patch) | |
| tree | 309a8132b44564b9e634c0da6815187ce8eab27c /gnu/llvm/unittests/Support/ConvertUTFTest.cpp | |
| parent | killp -a should not kill the window if only one pane. (diff) | |
| download | wireguard-openbsd-bd3306aecb3a15e8967143b8cdbbccf2b1b19b74.tar.xz wireguard-openbsd-bd3306aecb3a15e8967143b8cdbbccf2b1b19b74.zip | |
Import LLVM 3.9.1 including clang and lld.
Diffstat (limited to 'gnu/llvm/unittests/Support/ConvertUTFTest.cpp')
| -rw-r--r-- | gnu/llvm/unittests/Support/ConvertUTFTest.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/gnu/llvm/unittests/Support/ConvertUTFTest.cpp b/gnu/llvm/unittests/Support/ConvertUTFTest.cpp index d436fc02289..0af09e98a21 100644 --- a/gnu/llvm/unittests/Support/ConvertUTFTest.cpp +++ b/gnu/llvm/unittests/Support/ConvertUTFTest.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ConvertUTF.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Format.h" #include "gtest/gtest.h" #include <string> @@ -59,7 +60,7 @@ TEST(ConvertUTFTest, OddLengthInput) { TEST(ConvertUTFTest, Empty) { std::string Result; - bool Success = convertUTF16ToUTF8String(None, Result); + bool Success = convertUTF16ToUTF8String(llvm::ArrayRef<char>(None), Result); EXPECT_TRUE(Success); EXPECT_TRUE(Result.empty()); } @@ -80,6 +81,41 @@ TEST(ConvertUTFTest, HasUTF16BOM) { EXPECT_FALSE(HasBOM); } +TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) { + // Src is the look of disapproval. + static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c"; + ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4); + std::string Result; + bool Success = convertUTF16ToUTF8String(SrcRef, Result); + EXPECT_TRUE(Success); + std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); + EXPECT_EQ(Expected, Result); +} + +TEST(ConvertUTFTest, ConvertUTF8toWide) { + // Src is the look of disapproval. + static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0"; + std::wstring Result; + bool Success = ConvertUTF8toWide((const char*)Src, Result); + EXPECT_TRUE(Success); + std::wstring Expected(L"\x0ca0_\x0ca0"); + EXPECT_EQ(Expected, Result); + Result.clear(); + Success = ConvertUTF8toWide(StringRef(Src, 7), Result); + EXPECT_TRUE(Success); + EXPECT_EQ(Expected, Result); +} + +TEST(ConvertUTFTest, convertWideToUTF8) { + // Src is the look of disapproval. + static const wchar_t Src[] = L"\x0ca0_\x0ca0"; + std::string Result; + bool Success = convertWideToUTF8(Src, Result); + EXPECT_TRUE(Success); + std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); + EXPECT_EQ(Expected, Result); +} + struct ConvertUTFResultContainer { ConversionResult ErrorCode; std::vector<unsigned> UnicodeScalars; |
