MCPcopy Create free account
hub / github.com/boostorg/beast / testChunkExtensions

Method testChunkExtensions

test/beast/http/chunk_encode.cpp:189–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 }
188
189 void
190 testChunkExtensions()
191 {
192 auto const str =
193 [](chunk_extensions const& ce)
194 {
195 std::string s;
196 for(auto const& v : ce)
197 {
198 s.append(std::string(v.first));
199 s.push_back(',');
200 if(! v.second.empty())
201 {
202 s.append(std::string(v.second));
203 s.push_back(',');
204 }
205 }
206 return s;
207 };
208 chunk_extensions ce;
209 ce.insert("x");
210 BEAST_EXPECT(ce.str() == ";x");
211 BEAST_EXPECT(str(ce) == "x,");
212 ce.insert("y", "z");
213 BEAST_EXPECT(ce.str() == ";x;y=z");
214 BEAST_EXPECT(str(ce) == "x,y,z,");
215 ce.insert("z", R"(")");
216 BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"")");
217 BEAST_EXPECT(str(ce) == R"(x,y,z,z,",)");
218 ce.insert("p", R"(\)");
219 BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\")");
220 BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,)");
221 ce.insert("q", R"(1"2\)");
222 BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\";q="1\"2\\")");
223 BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,q,1"2\,)");
224 }
225
226 void
227 testParseChunkExtensions()

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.45
insertMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected