MCPcopy Create free account
hub / github.com/cutelyst/cutelyst / testController_data

Method testController_data

tests/testcontext.cpp:164–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164void TestContext::testController_data()
165{
166 QTest::addColumn<QString>("url");
167 QTest::addColumn<QByteArray>("output");
168
169 // UriFor
170 QUrlQuery query;
171 query.addQueryItem(u"path"_s, u"/root"_s);
172 QTest::newRow("urifor-test00") << u"/uriFor?"_s + query.toString(QUrl::FullyEncoded)
173 << QByteArrayLiteral("http://127.0.0.1/root");
174
175 query.clear();
176 query.addQueryItem(u"path"_s, u"/root/"_s);
177 QTest::newRow("urifor-test01") << u"/uriFor?"_s + query.toString(QUrl::FullyEncoded)
178 << QByteArrayLiteral("http://127.0.0.1/root/");
179
180 query.clear();
181 query.addQueryItem(u"path"_s, u"/root"_s);
182 QTest::newRow("urifor-test02") << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
183 << QByteArrayLiteral("http://127.0.0.1/root/a/b/c");
184
185 query.clear();
186 query.addQueryItem(u"path"_s, u"/root/"_s);
187 QTest::newRow("urifor-test03") << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
188 << QByteArrayLiteral("http://127.0.0.1/root//a/b/c");
189
190 query.clear();
191 query.addQueryItem(u"path"_s, u"/new/path"_s);
192 query.addQueryItem(u"foo"_s, u"bar"_s);
193 query.addQueryItem(u"encoded"_s, u"瀢"_s);
194 QTest::newRow("urifor-test04")
195 << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
196 << QByteArrayLiteral(
197 "http://127.0.0.1/new/path/a/b/c?foo=bar&encoded=\xC3\xA7\xE2\x82\xAC\xC2\xA2");
198
199 query.clear();
200 query.addQueryItem(u"path"_s, u"/new/path///"_s);
201 query.addQueryItem(u"foo"_s, u"bar"_s);
202 query.addQueryItem(u"encoded"_s, u"瀢"_s);
203 QTest::newRow("urifor-test05")
204 << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
205 << QByteArrayLiteral(
206 "http://127.0.0.1/new/path////a/b/c?foo=bar&encoded=\xC3\xA7\xE2\x82\xAC\xC2\xA2");
207
208 query.clear();
209 query.addQueryItem(u"path"_s, u"root"_s); // no leading slash
210 query.addQueryItem(u"foo"_s, u"bar"_s);
211 QTest::newRow("urifor-test06") << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
212 << QByteArrayLiteral("http://127.0.0.1/root/a/b/c?foo=bar");
213
214 query.clear();
215 query.addQueryItem(u"path"_s,
216 u""_s); // empty path to test controller->ns()
217 query.addQueryItem(u"foo"_s, u"bar"_s);
218 QTest::newRow("urifor-test07")
219 << u"/uriFor/a/b/c?"_s + query.toString(QUrl::FullyEncoded)
220 << QByteArrayLiteral("http://127.0.0.1/test/controller/a/b/c?foo=bar");
221

Callers

nothing calls this directly

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected