| 273 | } |
| 274 | |
| 275 | void TestResponse::testController_data() |
| 276 | { |
| 277 | QTest::addColumn<QByteArray>("method"); |
| 278 | QTest::addColumn<QString>("url"); |
| 279 | QTest::addColumn<Headers>("headers"); |
| 280 | QTest::addColumn<QByteArray>("body"); |
| 281 | QTest::addColumn<int>("responseStatus"); |
| 282 | QTest::addColumn<Headers>("responseHeaders"); |
| 283 | QTest::addColumn<QByteArray>("output"); |
| 284 | |
| 285 | const auto get = "GET"_ba; |
| 286 | const auto post = "POST"_ba; |
| 287 | |
| 288 | QUrlQuery query; |
| 289 | Headers headers; |
| 290 | |
| 291 | QTest::newRow("status-test00") |
| 292 | << get << u"/response/test/status?data=200"_s << headers << QByteArray() << 200 |
| 293 | << Headers{{"Content-Length", "3"}} << QByteArrayLiteral("200"); |
| 294 | |
| 295 | QTest::newRow("status-test01") |
| 296 | << get << u"/response/test/status?data=404"_s << headers << QByteArray() << 404 |
| 297 | << Headers{{"Content-Length", "3"}} << QByteArrayLiteral("404"); |
| 298 | |
| 299 | QTest::newRow("status-test02") |
| 300 | << get << u"/response/test/status?data=301"_s << headers << QByteArray() << 301 |
| 301 | << Headers{{"Content-Length", "3"}} << QByteArrayLiteral("301"); |
| 302 | |
| 303 | QTest::newRow("status-test03") |
| 304 | << get << u"/response/test/status?data=400"_s << headers << QByteArray() << 400 |
| 305 | << Headers{{"Content-Length", "3"}} << QByteArrayLiteral("400"); |
| 306 | |
| 307 | QTest::newRow("contentEncoding-test00") |
| 308 | << get << u"/response/test/contentEncoding?data=UTF-8"_s << headers << QByteArray() << 200 |
| 309 | << Headers{{"Content-Length", "5"}, {"Content-Encoding", "UTF-8"}} |
| 310 | << QByteArrayLiteral("UTF-8"); |
| 311 | |
| 312 | QTest::newRow("contentEncoding-test01") |
| 313 | << get << u"/response/test/contentEncoding?data=UTF-16"_s << headers << QByteArray() << 200 |
| 314 | << Headers{{"Content-Length", "6"}, {"Content-Encoding", "UTF-16"}} |
| 315 | << QByteArrayLiteral("UTF-16"); |
| 316 | |
| 317 | QTest::newRow("contentLength-test00") |
| 318 | << get << u"/response/test/contentLength?data=Hello"_s << headers << QByteArray() << 200 |
| 319 | << Headers{{"Content-Length", "5"}} << QByteArrayLiteral("Hello"); |
| 320 | |
| 321 | QTest::newRow("contentLengthIODevice-test00") |
| 322 | << get << u"/response/test/contentLengthIODevice?data=HelloWorld"_s << headers |
| 323 | << QByteArray() << 200 << Headers{{"Content-Length", "10"}} |
| 324 | << QByteArrayLiteral("HelloWorld"); |
| 325 | |
| 326 | query.clear(); |
| 327 | query.addQueryItem(u"data"_s, u"appplication/json"_s); |
| 328 | QTest::newRow("contentType-test00") |
| 329 | << get << u"/response/test/contentType?"_s + query.toString(QUrl::FullyEncoded) << headers |
| 330 | << QByteArray() << 200 |
| 331 | << Headers{{"Content-Length", "17"}, {"Content-Type", "appplication/json"}} |
| 332 | << QByteArrayLiteral("appplication/json"); |
nothing calls this directly
no test coverage detected