Line data Source code
1 : // Copyright 2019 the V8 project 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 : #include "src/torque/utils.h"
6 : #include "test/unittests/test-utils.h"
7 :
8 : namespace v8 {
9 : namespace internal {
10 : namespace torque {
11 :
12 15443 : TEST(TorqueUtils, FileUriDecodeIllegal) {
13 3 : EXPECT_EQ(FileUriDecode("http://wrong.scheme"), base::nullopt);
14 3 : EXPECT_EQ(FileUriDecode("file://wrong-escape%"), base::nullopt);
15 3 : EXPECT_EQ(FileUriDecode("file://another-wrong-escape%a"), base::nullopt);
16 3 : EXPECT_EQ(FileUriDecode("file://no-hex-escape%0g"), base::nullopt);
17 1 : }
18 :
19 15443 : TEST(TorqueUtils, FileUriDecode) {
20 3 : EXPECT_EQ(FileUriDecode("file:///some/src/file.tq").value(),
21 0 : "/some/src/file.tq");
22 3 : EXPECT_EQ(FileUriDecode("file:///c%3A/torque/base.tq").value(),
23 0 : "/c:/torque/base.tq");
24 3 : EXPECT_EQ(FileUriDecode("file:///d%3a/lower/hex.txt").value(),
25 0 : "/d:/lower/hex.txt");
26 1 : }
27 :
28 : } // namespace torque
29 : } // namespace internal
30 9264 : } // namespace v8
|