• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The V8 Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // This file is V8 specific, to make encoding_test.cc work.
6 // It is not rolled from the upstream project.
7 
8 #ifndef V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_
9 #define V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "src/base/logging.h"
15 #include "src/inspector/v8-string-conversions.h"
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 
19 namespace v8_inspector_protocol_encoding {
20 
UTF16ToUTF8(span<uint16_t> in)21 std::string UTF16ToUTF8(span<uint16_t> in) {
22   return v8_inspector::UTF16ToUTF8(in.data(), in.size());
23 }
24 
UTF8ToUTF16(span<uint8_t> in)25 std::vector<uint16_t> UTF8ToUTF16(span<uint8_t> in) {
26   std::basic_string<uint16_t> utf16 = v8_inspector::UTF8ToUTF16(
27       reinterpret_cast<const char*>(in.data()), in.size());
28   return std::vector<uint16_t>(utf16.begin(), utf16.end());
29 }
30 
31 }  // namespace v8_inspector_protocol_encoding
32 
33 #endif  // V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_TEST_HELPER_H_
34