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