0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 07:00:59 +01:00
nodejs/tools/inspector_protocol/encoding/encoding_test_helper.h
Michaël Zasso 5aaa7fee2e tools: update inspector_protocol to 0aafd2
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/27770
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-01 09:28:34 +02:00

34 lines
1.1 KiB
C++

// 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_