@@ -448,3 +448,49 @@ TEST(url_search_params, sort_unicode_code_units_edge_case) {
448448 ASSERT_EQ (keys.next (), " \xf0\x9f\x8c\x88\xef\xac\x83 " );
449449 SUCCEED ();
450450}
451+
452+ TEST (url_search_params, to_raw_string_no_normalization) {
453+ auto params = ada::url_search_params ();
454+ params.append (" a" , " b c" );
455+ // to_string normalizes space to +
456+ ASSERT_EQ (params.to_string (), " a=b+c" );
457+ // to_raw_string preserves %20 encoding
458+ ASSERT_EQ (params.to_raw_string (), " a=b%20c" );
459+ SUCCEED ();
460+ }
461+
462+ TEST (url_search_params, to_raw_string_with_special_chars) {
463+ auto params = ada::url_search_params ();
464+ params.append (" key1" , " value with spaces" );
465+ params.append (" key2" , " another value" );
466+ // to_string normalizes spaces to +
467+ ASSERT_EQ (params.to_string (), " key1=value+with+spaces&key2=another+value" );
468+ // to_raw_string preserves %20 encoding
469+ ASSERT_EQ (params.to_raw_string (),
470+ " key1=value%20with%20spaces&key2=another%20value" );
471+ SUCCEED ();
472+ }
473+
474+ TEST (url_search_params, to_raw_string_with_accents) {
475+ auto params = ada::url_search_params ();
476+ params.append (" key1" , " \u00E9 t\u00E9 " );
477+ params.append (" key2" , " C\u00E9 line Dion++" );
478+ // Both should encode accents the same way
479+ // to_string normalizes spaces to +, to_raw_string uses %20
480+ // Note: + signs are not encoded by QUERY_PERCENT_ENCODE
481+ ASSERT_EQ (params.to_string (),
482+ " key1=%C3%A9t%C3%A9&key2=C%C3%A9line+Dion%2B%2B" );
483+ ASSERT_EQ (params.to_raw_string (),
484+ " key1=%C3%A9t%C3%A9&key2=C%C3%A9line%20Dion++" );
485+ SUCCEED ();
486+ }
487+
488+ TEST (url_search_params, to_raw_string_empty_values) {
489+ auto params = ada::url_search_params ();
490+ params.append (" a" , " " );
491+ params.append (" " , " b" );
492+ params.append (" " , " " );
493+ ASSERT_EQ (params.to_raw_string (), " a=&=b&=" );
494+ ASSERT_EQ (params.to_string (), " a=&=b&=" );
495+ SUCCEED ();
496+ }
0 commit comments