@@ -71,61 +71,6 @@ TEST(RestUtilTest, RoundTripUrlEncodeDecodeNamespace) {
7171 EXPECT_THAT (DecodeNamespace (" " ), HasValue (::testing::Eq (Namespace{.levels = {}})));
7272}
7373
74- TEST (RestUtilTest, EncodeString) {
75- // RFC 3986 unreserved characters should not be encoded
76- EXPECT_THAT (EncodeString (" abc123XYZ" ), HasValue (::testing::Eq (" abc123XYZ" )));
77- EXPECT_THAT (EncodeString (" test-file_name.txt~backup" ),
78- HasValue (::testing::Eq (" test-file_name.txt~backup" )));
79-
80- // Spaces and special characters should be encoded
81- EXPECT_THAT (EncodeString (" hello world" ), HasValue (::testing::Eq (" hello%20world" )));
82- EXPECT_THAT (EncodeString (" test@example.com" ),
83- HasValue (::testing::Eq (" test%40example.com" )));
84- EXPECT_THAT (EncodeString (" path/to/file" ), HasValue (::testing::Eq (" path%2Fto%2Ffile" )));
85- EXPECT_THAT (EncodeString (" key=value&foo=bar" ),
86- HasValue (::testing::Eq (" key%3Dvalue%26foo%3Dbar" )));
87- EXPECT_THAT (EncodeString (" 100%" ), HasValue (::testing::Eq (" 100%25" )));
88- EXPECT_THAT (EncodeString (" hello\x1F world" ), HasValue (::testing::Eq (" hello%1Fworld" )));
89- EXPECT_THAT (EncodeString (" " ), HasValue (::testing::Eq (" " )));
90- }
91-
92- TEST (RestUtilTest, DecodeString) {
93- // Decode percent-encoded strings
94- EXPECT_THAT (DecodeString (" hello%20world" ), HasValue (::testing::Eq (" hello world" )));
95- EXPECT_THAT (DecodeString (" test%40example.com" ),
96- HasValue (::testing::Eq (" test@example.com" )));
97- EXPECT_THAT (DecodeString (" path%2Fto%2Ffile" ), HasValue (::testing::Eq (" path/to/file" )));
98- EXPECT_THAT (DecodeString (" key%3Dvalue%26foo%3Dbar" ),
99- HasValue (::testing::Eq (" key=value&foo=bar" )));
100- EXPECT_THAT (DecodeString (" 100%25" ), HasValue (::testing::Eq (" 100%" )));
101-
102- // ASCII Unit Separator (0x1F)
103- EXPECT_THAT (DecodeString (" hello%1Fworld" ), HasValue (::testing::Eq (" hello\x1F world" )));
104-
105- // Unreserved characters remain unchanged
106- EXPECT_THAT (DecodeString (" test-file_name.txt~backup" ),
107- HasValue (::testing::Eq (" test-file_name.txt~backup" )));
108- EXPECT_THAT (DecodeString (" " ), HasValue (::testing::Eq (" " )));
109- }
110-
111- TEST (RestUtilTest, EncodeDecodeStringRoundTrip) {
112- std::vector<std::string> test_cases = {" hello world" ,
113- " test@example.com" ,
114- " path/to/file" ,
115- " key=value&foo=bar" ,
116- " 100%" ,
117- " hello\x1F world" ,
118- " special!@#$%^&*()chars" ,
119- " mixed-123_test.file~ok" ,
120- " " };
121-
122- for (const auto & test : test_cases) {
123- ICEBERG_UNWRAP_OR_FAIL (std::string encoded, EncodeString (test));
124- ICEBERG_UNWRAP_OR_FAIL (std::string decoded, DecodeString (encoded));
125- EXPECT_EQ (decoded, test) << " Round-trip failed for: " << test;
126- }
127- }
128-
12974TEST (RestUtilTest, MergeConfigs) {
13075 std::unordered_map<std::string, std::string> server_defaults = {
13176 {" default1" , " value1" }, {" default2" , " value2" }, {" common" , " default_value" }};
0 commit comments