File: encoding_test_helper.h

package info (click to toggle)
nodejs 20.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 219,072 kB
  • sloc: cpp: 1,277,408; javascript: 565,332; ansic: 129,476; python: 58,536; sh: 3,841; makefile: 2,725; asm: 1,732; perl: 248; lisp: 222; xml: 42
file content (33 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2019 The V8 Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is V8 specific, to make encoding_test.cc work.
// It is not rolled from the upstream project.

#ifndef V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_
#define V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_

#include <string>
#include <vector>

#include "src/base/logging.h"
#include "src/inspector/v8-string-conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8_inspector_protocol_encoding {

std::string UTF16ToUTF8(span<uint16_t> in) {
  return v8_inspector::UTF16ToUTF8(in.data(), in.size());
}

std::vector<uint16_t> UTF8ToUTF16(span<uint8_t> in) {
  std::basic_string<uint16_t> utf16 = v8_inspector::UTF8ToUTF16(
      reinterpret_cast<const char*>(in.data()), in.size());
  return std::vector<uint16_t>(utf16.begin(), utf16.end());
}

}  // namespace v8_inspector_protocol_encoding

#endif  // V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_