From fe2efd13819d5eef73859ab06138233585f99fe7 Mon Sep 17 00:00:00 2001 From: Nicholas Paun Date: Thu, 30 Jan 2025 14:10:00 -0800 Subject: [PATCH] Add a regression test for url_search_params::sort taken from WPT --- tests/url_search_params.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/url_search_params.cpp b/tests/url_search_params.cpp index a9002abcc..a86d27011 100644 --- a/tests/url_search_params.cpp +++ b/tests/url_search_params.cpp @@ -123,6 +123,19 @@ TEST(url_search_params, sort) { SUCCEED(); } +// Taken from +// https://github.com/web-platform-tests/wpt/blob/d5085f61e2d949bc9fb24b04f4c6a47bdf6d3be9/url/urlsearchparams-sort.any.js#L11 +TEST(url_search_params, sort_unicode_code_units) { + ada::url_search_params search_params( + "ffi&🌈"); // 🌈 > code point, but < code unit because two code units + search_params.sort(); + ASSERT_EQ(search_params.size(), 2); + auto keys = search_params.get_keys(); + ASSERT_EQ(keys.next(), "🌈"); + ASSERT_EQ(keys.next(), "ffi"); + SUCCEED(); +} + TEST(url_search_params, string_constructor) { auto p = ada::url_search_params("?a=b"); ASSERT_EQ(p.to_string(), "a=b");