Skip to content

Commit

Permalink
feat: implement parsing for expected_match field
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcanaltin committed Jan 2, 2025
1 parent 6b79301 commit b7d36da
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/wpt_urlpattern_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,36 @@ TEST(wpt_urlpattern_tests, urlpattern_test_data) {
// - null
// - {} // response here.
auto input_value = parse_inputs_array(inputs);
// TODO: Parse "expected_match" field here.

ondemand::value expected_match_value;
if (main_object["expected_match"].get(expected_match_value)) {
if (expected_match_value.type() ==
simdjson::ondemand::json_type::string) {
std::string_view expected_match_str;
if (expected_match_value.get_string().get(expected_match_str)) {
std::cout << "Expected match (string): " << expected_match_str
<< std::endl;
}
}
else if (expected_match_value.type() ==
simdjson::ondemand::json_type::null) {
std::cout << "Expected match is null." << std::endl;
}
else if (expected_match_value.type() ==
simdjson::ondemand::json_type::object) {
try {
auto expected_match_obj = expected_match_value.get_object();
std::cout << "Expected match is an object." << std::endl;
} catch (const simdjson::simdjson_error& e) {
std::cerr << "Error processing object: " << e.what() << std::endl;
}
} else {
std::cout << "Unexpected type for expected_match." << std::endl;
}
} else {
std::cout << "Expected match field not found or invalid."
<< std::endl;
}
}
}
} catch (simdjson_error& error) {
Expand Down

0 comments on commit b7d36da

Please sign in to comment.