MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/util/utf8_util_test.cc:319–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319TEST(SkipUTF8BOM, Basics) {
320 auto CheckOk = [](const std::string& s, size_t expected_offset) -> void {
321 const uint8_t* data = reinterpret_cast<const uint8_t*>(s.data());
322 const uint8_t* res;
323 ASSERT_OK_AND_ASSIGN(res, SkipUTF8BOM(data, static_cast<int64_t>(s.size())));
324 ASSERT_NE(res, nullptr);
325 ASSERT_EQ(res - data, expected_offset);
326 };
327
328 auto CheckTruncated = [](const std::string& s) -> void {
329 const uint8_t* data = reinterpret_cast<const uint8_t*>(s.data());
330 ASSERT_RAISES(Invalid, SkipUTF8BOM(data, static_cast<int64_t>(s.size())));
331 };
332
333 CheckOk("", 0);
334 CheckOk("a", 0);
335 CheckOk("ab", 0);
336 CheckOk("abc", 0);
337 CheckOk("abcd", 0);
338 CheckOk("\xc3\xa9", 0);
339 CheckOk("\xee", 0);
340 CheckOk("\xef\xbc", 0);
341 CheckOk("\xef\xbb\xbe", 0);
342 CheckOk("\xef\xbb\xbf", 3);
343 CheckOk("\xef\xbb\xbfx", 3);
344
345 CheckTruncated("\xef");
346 CheckTruncated("\xef\xbb");
347}
348
349// Currently a known issue with Valgrind and wide string AVX2 instructions
350// https://sourceware.org/bugzilla/show_bug.cgi?id=22954

Callers

nothing calls this directly

Calls 13

SkipUTF8BOMFunction · 0.85
UTF8ToWideStringFunction · 0.85
UTF8StringToUTF16Function · 0.85
UTF16StringToUTF8Function · 0.85
UTF8DecodeReverseFunction · 0.85
UTF8FindIfFunction · 0.85
UTF8FindIfReverseFunction · 0.85
UTF8LengthFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
lengthFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected