chromium/third_party/perfetto/src/trace_processor/importers/proto/string_encoding_utils_unittests.cc


/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "perfetto/protozero/field.h"
#include "src/trace_processor/importers/proto/string_encoding_utils.h"

#include <cstdint>
#include <cstring>
#include <limits>
#include <string>

#include "perfetto/ext/base/string_view.h"
#include "test/gtest_and_gmock.h"

namespace perfetto {
namespace trace_processor {
namespace {

ConstBytes;
Eq;
SizeIs;

TEST(ConvertLatin1ToUtf8, FullCodePage) {}

// The following strings are different encodings of the following code points:
//     \u0000, \u0001, \u0002, \u0005, \u000A, \u0015, \u002A, \u0055, \u00AA,
//     \u0155, \u02AA, \u0555, \u0AAA, \u1555, \u2AAA, \u5555, \uAAAA,
//     \U00015555, \U0002AAAA, \U00055555, \U000AAAAA, \U0010AAAA
// This gives a reasonable coverage of the entire code point range so that we
// force all types of encoding, ie utf8: 1-4 bytes, utf16: with and without
// surrogate pairs
const uint8_t kUtf16Le[] =;

const uint8_t kUtf16Be[] =;

const uint8_t kExpectedUtf8[] =;

// Collection of invalid bytes: High surrogate followed by non low surrogate,
// low surrogate, 1 random byte (not enough to read one code unit which is 2
// bytes)
const uint8_t kInvalidUtf16Le[] =;
const uint8_t kInvalidUtf16Be[] =;

// We expect 3 invalid char code points.
const uint8_t kExpectedUtf8ForInvalidUtf16[] =;

TEST(ConvertUtf16LeToUtf8, ValidInput) {}

TEST(ConvertUtf16BeToUtf8, ValidInput) {}

TEST(ConvertUtf16LeToUtf8, InvalidValidInput) {}

TEST(ConvertUtf16BeToUtf8, InvalidValidInput) {}

}  // namespace

}  // namespace trace_processor
}  // namespace perfetto