Commit 5ae50165 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Add unittest for upstream encoding library.

This brings in
third_party/inspector_protocol/encoding/encoding_test.cc
from the upstream project and makes it work for v8's
unittest suite.

encoding_test_helper.h is a V8 specific implementation,
which delegates to src/inspector/v8-string-conversions{.h,.cc},
for the utf8 / utf16 conversion routines.

I'm also fixing / updating roll.py, for future rolls.

Change-Id: I08e4784838ff81ef3ac328f783512b42c91b6bcd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1597215Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61393}
parent 72a11c12
......@@ -295,6 +295,7 @@ v8_source_set("unittests_sources") {
"../..:v8_for_testing",
"../..:v8_libbase",
"../..:v8_libplatform",
"../../third_party/inspector_protocol:encoding_test",
"//build/win:default_exe_manifest",
"//testing/gmock",
"//testing/gtest",
......
......@@ -8,3 +8,27 @@ static_library("encoding") {
"encoding/encoding.h",
]
}
# encoding_test is part of the unittests, defined in
# test/unittests/BUILD.gn.
import("../../gni/v8.gni")
v8_source_set("encoding_test") {
sources = [
"encoding/encoding_test.cc",
"encoding/encoding_test_helper.h",
]
configs = [
"../..:external_config",
"../..:internal_config_base",
]
deps = [
":encoding",
"../..:v8_libbase",
"../../src/inspector:inspector_string_conversions",
"//testing/gmock",
"//testing/gtest",
]
testonly = true
}
......@@ -13,6 +13,7 @@
#include <vector>
namespace v8_inspector_protocol_encoding {
// =============================================================================
// span - sequence of bytes
// =============================================================================
......
This diff is collapsed.
// 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_
......@@ -18,6 +18,9 @@ FILES_TO_SYNC = [
'code_generator.py',
'concatenate_protocols.py',
'convert_protocol_to_json.py',
'encoding/encoding.h',
'encoding/encoding.cc',
'encoding/encoding_test.cc',
'inspector_protocol.gni',
'inspector_protocol.gypi',
'lib/*',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment