| 3305 | } |
| 3306 | |
| 3307 | void TestValidator::testValidatorNumeric_data() |
| 3308 | { |
| 3309 | QTest::addColumn<QString>("url"); |
| 3310 | QTest::addColumn<QByteArray>("body"); |
| 3311 | QTest::addColumn<QByteArray>("output"); |
| 3312 | |
| 3313 | // **** Start testing ValidatorNumeric ***** |
| 3314 | |
| 3315 | const QList<QString> validNumerics( |
| 3316 | {u"23"_s, u"-3465"_s, u"23.45"_s, u"-3456.32453245"_s, u"23.345345e15"_s, u"-1.23e4"_s}); |
| 3317 | |
| 3318 | int count = 0; |
| 3319 | QUrlQuery query; |
| 3320 | for (const QString &num : validNumerics) { |
| 3321 | query.clear(); |
| 3322 | query.addQueryItem(u"field"_s, num); |
| 3323 | QTest::newRow(qUtf8Printable(u"valid0%1"_s.arg(count))) |
| 3324 | << u"/numeric"_s << query.toString(QUrl::FullyEncoded).toLatin1() << valid; |
| 3325 | count++; |
| 3326 | } |
| 3327 | |
| 3328 | const QList<QString> invalidNumerics( |
| 3329 | {u"2s3"_s, u"-a3465"_s, u"23:45"_s, u"-3456:32453245"_s, u"23.345345c15"_s, u"-1.23D4"_s}); |
| 3330 | |
| 3331 | count = 0; |
| 3332 | for (const QString &num : invalidNumerics) { |
| 3333 | query.clear(); |
| 3334 | query.addQueryItem(u"field"_s, num); |
| 3335 | QTest::newRow(qUtf8Printable(u"invalid0%1"_s.arg(count))) |
| 3336 | << u"/numeric"_s << query.toString(QUrl::FullyEncoded).toLatin1() << invalid; |
| 3337 | count++; |
| 3338 | } |
| 3339 | |
| 3340 | query.clear(); |
| 3341 | query.addQueryItem(u"field"_s, u"%20"_s); |
| 3342 | QTest::newRow("empty") << u"/numeric"_s << query.toString(QUrl::FullyEncoded).toLatin1() |
| 3343 | << valid; |
| 3344 | } |
| 3345 | |
| 3346 | void TestValidator::testValidatorPresent_data() |
| 3347 | { |