#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "url/url_canon.h"
#include <errno.h>
#include <stddef.h>
#include <string_view>
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_canon_internal.h"
#include "url/url_canon_stdstring.h"
#include "url/url_features.h"
#include "url/url_test_utils.h"
namespace url {
namespace {
struct ComponentCase { … };
struct DualComponentCase { … };
struct IPAddressCase { … };
struct ReplaceCase { … };
const char kDeleteComp[] = …;
template<typename CHAR>
void SetupReplComp(
void (Replacements<CHAR>::*set)(const CHAR*, const Component&),
void (Replacements<CHAR>::*clear)(),
Replacements<CHAR>* rep,
const CHAR* str) { … }
bool CanonicalizeSpecialPath(const char* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
bool CanonicalizeSpecialPath(const char16_t* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
bool CanonicalizeNonSpecialPath(const char* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
bool CanonicalizeNonSpecialPath(const char16_t* spec,
const Component& path,
CanonOutput* output,
Component* out_path) { … }
}
TEST(URLCanonTest, DoAppendUTF8) { … }
TEST(URLCanonTest, DoAppendUTF8Invalid) { … }
TEST(URLCanonTest, UTF) { … }
TEST(URLCanonTest, Scheme) { … }
enum class IDNAMode { … };
class URLCanonHostTest
: public ::testing::Test,
public ::testing::WithParamInterface<IDNAMode> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(URLCanonHostTest, Host) { … }
TEST(URLCanonTest, SpecialHostPuncutationChar) { … }
TEST(URLCanonTest, ForbiddenHostCodePoint) { … }
TEST(URLCanonTest, IPv4) { … }
TEST(URLCanonTest, IPv6) { … }
TEST(URLCanonTest, IPEmpty) { … }
TEST(URLCanonTest, CanonicalizeHostSubstring) { … }
TEST(URLCanonTest, UserInfo) { … }
TEST(URLCanonTest, Port) { … }
DualComponentCase kCommonPathCases[] = …;
CanonFunc8Bit;
CanonFunc16Bit;
void DoPathTest(const DualComponentCase* path_cases,
size_t num_cases,
CanonFunc8Bit canon_func_8,
CanonFunc16Bit canon_func_16) { … }
TEST(URLCanonTest, SpecialPath) { … }
TEST(URLCanonTest, NonSpecialPath) { … }
TEST(URLCanonTest, PartialPath) { … }
TEST(URLCanonTest, Query) { … }
TEST(URLCanonTest, Ref) { … }
TEST(URLCanonTest, CanonicalizeStandardURL) { … }
TEST(URLCanonTest, CanonicalizeNonSpecialURL) { … }
TEST(URLCanonTest, CanonicalizeNonSpecialURLOutputParsed) { … }
TEST(URLCanonTest, ReplaceStandardURL) { … }
TEST(URLCanonTest, ReplaceFileURL) { … }
TEST(URLCanonTest, ReplaceFileSystemURL) { … }
TEST(URLCanonTest, ReplacePathURL) { … }
TEST(URLCanonTest, ReplaceMailtoURL) { … }
TEST(URLCanonTest, CanonicalizeFileURL) { … }
TEST(URLCanonTest, CanonicalizeFileSystemURL) { … }
TEST(URLCanonTest, CanonicalizePathURL) { … }
TEST(URLCanonTest, CanonicalizePathURLPath) { … }
TEST(URLCanonTest, CanonicalizeMailtoURL) { … }
#ifndef WIN32
TEST(URLCanonTest, _itoa_s) { … }
TEST(URLCanonTest, _itow_s) { … }
#endif
static bool ParsedIsEqual(const Parsed& a, const Parsed& b) { … }
TEST(URLCanonTest, ResolveRelativeURL) { … }
class URLCanonTypedTest : public ::testing::TestWithParam<bool> { … };
TEST_P(URLCanonTypedTest, NonSpecialResolveRelativeURL) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(URLCanonTest, ReplacementOverflow) { … }
TEST(URLCanonTest, DefaultPortForScheme) { … }
TEST(URLCanonTest, FindWindowsDriveLetter) { … }
TEST(URLCanonTest, IDNToASCII) { … }
void ComponentCaseMatches(bool success,
std::string_view out_str,
const Component& out_comp,
const DualComponentCase& expected) { … }
TEST(URLCanonTest, OpaqueHost) { … }
void IPAddressCaseMatches(std::string_view out_str,
const CanonHostInfo& host_info,
const IPAddressCase& expected) { … }
TEST(URLCanonTest, NonSpecialHostIPv6Address) { … }
}