2019-03-05 10:01:53 +00:00
|
|
|
// 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) {
|
2019-04-23 20:49:34 +00:00
|
|
|
#ifdef V8_OS_WIN
|
2019-03-05 10:01:53 +00:00
|
|
|
EXPECT_EQ(FileUriDecode("file:///c%3A/torque/base.tq").value(),
|
2019-04-23 20:49:34 +00:00
|
|
|
"c:/torque/base.tq");
|
2019-03-05 10:01:53 +00:00
|
|
|
EXPECT_EQ(FileUriDecode("file:///d%3a/lower/hex.txt").value(),
|
2019-04-23 20:49:34 +00:00
|
|
|
"d:/lower/hex.txt");
|
|
|
|
#else
|
|
|
|
EXPECT_EQ(FileUriDecode("file:///some/src/file.tq").value(),
|
|
|
|
"/some/src/file.tq");
|
|
|
|
#endif
|
2019-03-05 10:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace torque
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|