Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I think that the test is in error #810

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions include/ada/url_pattern_helpers-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ inline void Tokenizer::get_next_code_point() {
code_point = first_byte;
ada_log("Tokenizer::get_next_code_point returning ASCII code point=",
uint32_t(code_point));
ada_log("Tokenizer::get_next_code_point next_index =", next_index, " input.size() =", input.size());
ada_log("Tokenizer::get_next_code_point next_index =", next_index,
" input.size()=", input.size());
return;
}
ada_log("Tokenizer::get_next_code_point read first byte=",
uint32_t(first_byte));
uint32_t(first_byte));
if ((first_byte & 0xE0) == 0xC0) {
code_point = first_byte & 0x1F;
number_bytes = 2;
Expand All @@ -338,17 +339,17 @@ inline void Tokenizer::get_next_code_point() {
number_bytes = 4;
ada_log("Tokenizer::get_next_code_point four bytes");
}
ADA_ASSERT_TRUE(number_bytes + next_index < input.size());
ADA_ASSERT_TRUE(number_bytes + next_index <= input.size());

for (size_t i = 1 + next_index; i < number_bytes + next_index; ++i) {
unsigned char byte = input[i];
ada_log("Tokenizer::get_next_code_point read byte=",
uint32_t(byte));
ada_log("Tokenizer::get_next_code_point read byte=", uint32_t(byte));
code_point = (code_point << 6) | (byte & 0x3F);
}
ada_log("Tokenizer::get_next_code_point returning non-ASCII code point=",
uint32_t(code_point));
ada_log("Tokenizer::get_next_code_point next_index =", next_index, " input.size() =", input.size());
ada_log("Tokenizer::get_next_code_point next_index =", next_index,
" input.size()=", input.size());
next_index += number_bytes;
}

Expand Down
6 changes: 6 additions & 0 deletions src/url_pattern_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace ada::url_pattern_helpers {

inline std::optional<url_pattern_errors>
constructor_string_parser::compute_protocol_matches_special_scheme_flag() {
ada_log(
"constructor_string_parser::compute_protocol_matches_special_scheme_"
"flag");
// Let protocol string be the result of running make a component string given
// parser.
auto protocol_string = make_component_string();
Expand All @@ -18,6 +21,8 @@ constructor_string_parser::compute_protocol_matches_special_scheme_flag() {
protocol_string, canonicalize_protocol,
url_pattern_compile_component_options::DEFAULT);
if (!protocol_component) {
ada_log("url_pattern_component::compile failed for protocol_string ",
protocol_string);
return protocol_component.error();
}
// If the result of running protocol component matches a special scheme given
Expand Down Expand Up @@ -348,6 +353,7 @@ constructor_string_parser::parse(std::string_view input) {
// Run compute protocol matches a special scheme flag given parser.
if (const auto error =
parser.compute_protocol_matches_special_scheme_flag()) {
ada_log("compute_protocol_matches_special_scheme_flag failed");
return tl::unexpected(*error);
}
// Let next state be "pathname".
Expand Down
2 changes: 1 addition & 1 deletion tests/wpt_urlpattern_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TEST(wpt_urlpattern_tests, urlpattern_test_data) {

if (!main_object["expected_obj"].get_string().get(expected_obj) &&
expected_obj == "error") {
if (parse_result.has_value()) {
if (parse_result.value().has_value()) {
main_object.reset();
FAIL() << "Test should have failed but it didn't" << std::endl
<< main_object.raw_json().value() << std::endl;
Expand Down
Loading