v8/test/unittests/torque/torque-utils-unittest.cc
Simon Zünd e00f2de6b5 [torque-ls] Properly decode file URIs sent by the client
This CL changes the language server to store file paths as URIs and
decodes them on-demand during compilation. For now, this will
eliminate the need for an URI encoding function.

R=tebbi@chromium.org

Bug: v8:8880
Change-Id: If79f635cb60035f58712c1458ecca3bfa23a6e47
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1502992
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60025}
2019-03-05 10:36:38 +00:00

31 lines
1020 B
C++

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/torque/utils.h"
#include "test/unittests/test-utils.h"
namespace v8 {
namespace internal {
namespace torque {
TEST(TorqueUtils, FileUriDecodeIllegal) {
EXPECT_EQ(FileUriDecode("http://wrong.scheme"), base::nullopt);
EXPECT_EQ(FileUriDecode("file://wrong-escape%"), base::nullopt);
EXPECT_EQ(FileUriDecode("file://another-wrong-escape%a"), base::nullopt);
EXPECT_EQ(FileUriDecode("file://no-hex-escape%0g"), base::nullopt);
}
TEST(TorqueUtils, FileUriDecode) {
EXPECT_EQ(FileUriDecode("file:///some/src/file.tq").value(),
"/some/src/file.tq");
EXPECT_EQ(FileUriDecode("file:///c%3A/torque/base.tq").value(),
"/c:/torque/base.tq");
EXPECT_EQ(FileUriDecode("file:///d%3a/lower/hex.txt").value(),
"/d:/lower/hex.txt");
}
} // namespace torque
} // namespace internal
} // namespace v8