| 7 | namespace ValdiTest { |
| 8 | |
| 9 | TEST(UTF16ToUTF32Index, canResolveIndexesOnEqualLength) { |
| 10 | std::string_view str = "Hello World\n"; |
| 11 | |
| 12 | std::vector<uint32_t> utf32; |
| 13 | std::vector<char16_t> utf16; |
| 14 | |
| 15 | for (auto c : str) { |
| 16 | utf32.emplace_back(static_cast<uint32_t>(c)); |
| 17 | utf16.emplace_back(static_cast<char16_t>(c)); |
| 18 | } |
| 19 | |
| 20 | UTF16ToUTF32Index index(utf16.data(), utf16.size(), utf32.data(), utf32.size()); |
| 21 | |
| 22 | ASSERT_EQ(static_cast<size_t>(0), index.getUTF32Index(0)); |
| 23 | ASSERT_EQ(static_cast<size_t>(5), index.getUTF32Index(5)); |
| 24 | ASSERT_EQ(static_cast<size_t>(11), index.getUTF32Index(11)); |
| 25 | // Out of bounds should still work |
| 26 | ASSERT_EQ(static_cast<size_t>(42), index.getUTF32Index(42)); |
| 27 | } |
| 28 | |
| 29 | TEST(UTF16ToUTF32Index, canResolveIndexesOnDifferentLength) { |
| 30 | std::string_view str = "مقدمة إلى \U0001F385\U0001F385\u2066C++ \U0001F385 ASCII \U0001F385\U0001F385 MORE ASCII " |
nothing calls this directly
no test coverage detected