MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

valdi/test/runtime/UTF_tests.cpp:9–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8namespace ValdiTest {
9
10TEST(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
30TEST(UTF16ToUTF32Index, canResolveIndexesOnDifferentLength) {

Callers

nothing calls this directly

Calls 5

utf8ToUtf16Function · 0.85
utf8ToUtf32Function · 0.85
getUTF32IndexMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected