Exclude denormal test cases if system doesn't support it
- current INTEGRITY development pack don't support denormals for float and double. All values are rounded to 0. Task-number: QTBUG-99123 Change-Id: Iaaacdc4210c7ac2ec3ec337c61164a1ade0efb01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 23fd249b85f6fd5e6c51b7f969460dab60c2554a)
This commit is contained in:
parent
425addb2a9
commit
fe7f9898b9
@ -402,6 +402,11 @@ void tst_QNumeric::distance()
|
|||||||
QFETCH(F, from);
|
QFETCH(F, from);
|
||||||
QFETCH(F, stop);
|
QFETCH(F, stop);
|
||||||
QFETCH(Count, expectedDistance);
|
QFETCH(Count, expectedDistance);
|
||||||
|
if constexpr (std::numeric_limits<F>::has_denorm != std::denorm_present) {
|
||||||
|
if (qstrcmp(QTest::currentDataTag(), "denormal") == 0) {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
|
}
|
||||||
QCOMPARE(qFloatDistance(from, stop), expectedDistance);
|
QCOMPARE(qFloatDistance(from, stop), expectedDistance);
|
||||||
QCOMPARE(qFloatDistance(stop, from), expectedDistance);
|
QCOMPARE(qFloatDistance(stop, from), expectedDistance);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,7 @@ private Q_SLOTS:
|
|||||||
void toJson();
|
void toJson();
|
||||||
void toJsonSillyNumericValues();
|
void toJsonSillyNumericValues();
|
||||||
void toJsonLargeNumericValues();
|
void toJsonLargeNumericValues();
|
||||||
|
void toJsonDenormalValues();
|
||||||
void fromJson();
|
void fromJson();
|
||||||
void fromJsonErrors();
|
void fromJsonErrors();
|
||||||
void parseNumbers();
|
void parseNumbers();
|
||||||
@ -393,12 +394,15 @@ void tst_QtJson::testNumbers_2()
|
|||||||
// Validate the last actual value is min denorm
|
// Validate the last actual value is min denorm
|
||||||
QVERIFY2(floatValues_1[1074] == 4.9406564584124654417656879286822e-324, QString("Min denorm value is incorrect: %1").arg(floatValues_1[1074]).toLatin1());
|
QVERIFY2(floatValues_1[1074] == 4.9406564584124654417656879286822e-324, QString("Min denorm value is incorrect: %1").arg(floatValues_1[1074]).toLatin1());
|
||||||
|
|
||||||
|
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
|
||||||
// Validate that every value is half the value before it up to 1
|
// Validate that every value is half the value before it up to 1
|
||||||
for (int index = 1074; index > 0; index--) {
|
for (int index = 1074; index > 0; index--) {
|
||||||
QVERIFY2(floatValues_1[index] != 0, QString("2**- %1 should not be 0").arg(index).toLatin1());
|
QVERIFY2(floatValues_1[index] != 0, QString("2**- %1 should not be 0").arg(index).toLatin1());
|
||||||
|
|
||||||
QVERIFY2(floatValues_1[index - 1] == (floatValues_1[index] * 2), QString("Value should be double adjacent value at index %1").arg(index).toLatin1());
|
QVERIFY2(floatValues_1[index - 1] == (floatValues_1[index] * 2), QString("Value should be double adjacent value at index %1").arg(index).toLatin1());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QtJson::testNumbers_3()
|
void tst_QtJson::testNumbers_3()
|
||||||
@ -1818,16 +1822,13 @@ void tst_QtJson::toJsonLargeNumericValues()
|
|||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
array.append(QJsonValue(1.234567)); // actual precision bug in Qt 5.0.0
|
array.append(QJsonValue(1.234567)); // actual precision bug in Qt 5.0.0
|
||||||
array.append(QJsonValue(1.7976931348623157e+308)); // JS Number.MAX_VALUE
|
array.append(QJsonValue(1.7976931348623157e+308)); // JS Number.MAX_VALUE
|
||||||
array.append(QJsonValue(5e-324)); // JS Number.MIN_VALUE
|
|
||||||
array.append(QJsonValue(std::numeric_limits<double>::min()));
|
array.append(QJsonValue(std::numeric_limits<double>::min()));
|
||||||
array.append(QJsonValue(std::numeric_limits<double>::max()));
|
array.append(QJsonValue(std::numeric_limits<double>::max()));
|
||||||
array.append(QJsonValue(std::numeric_limits<double>::epsilon()));
|
array.append(QJsonValue(std::numeric_limits<double>::epsilon()));
|
||||||
array.append(QJsonValue(std::numeric_limits<double>::denorm_min()));
|
|
||||||
array.append(QJsonValue(0.0));
|
array.append(QJsonValue(0.0));
|
||||||
array.append(QJsonValue(-std::numeric_limits<double>::min()));
|
array.append(QJsonValue(-std::numeric_limits<double>::min()));
|
||||||
array.append(QJsonValue(-std::numeric_limits<double>::max()));
|
array.append(QJsonValue(-std::numeric_limits<double>::max()));
|
||||||
array.append(QJsonValue(-std::numeric_limits<double>::epsilon()));
|
array.append(QJsonValue(-std::numeric_limits<double>::epsilon()));
|
||||||
array.append(QJsonValue(-std::numeric_limits<double>::denorm_min()));
|
|
||||||
array.append(QJsonValue(-0.0));
|
array.append(QJsonValue(-0.0));
|
||||||
array.append(QJsonValue(9007199254740992LL)); // JS Number max integer
|
array.append(QJsonValue(9007199254740992LL)); // JS Number max integer
|
||||||
array.append(QJsonValue(-9007199254740992LL)); // JS Number min integer
|
array.append(QJsonValue(-9007199254740992LL)); // JS Number min integer
|
||||||
@ -1841,27 +1842,21 @@ void tst_QtJson::toJsonLargeNumericValues()
|
|||||||
" 1.234567,\n"
|
" 1.234567,\n"
|
||||||
" 1.7976931348623157e+308,\n"
|
" 1.7976931348623157e+308,\n"
|
||||||
#ifdef QT_NO_DOUBLECONVERSION // "shortest" double conversion is not very short then
|
#ifdef QT_NO_DOUBLECONVERSION // "shortest" double conversion is not very short then
|
||||||
" 4.9406564584124654e-324,\n"
|
|
||||||
" 2.2250738585072014e-308,\n"
|
" 2.2250738585072014e-308,\n"
|
||||||
" 1.7976931348623157e+308,\n"
|
" 1.7976931348623157e+308,\n"
|
||||||
" 2.2204460492503131e-16,\n"
|
" 2.2204460492503131e-16,\n"
|
||||||
" 4.9406564584124654e-324,\n"
|
|
||||||
" 0,\n"
|
" 0,\n"
|
||||||
" -2.2250738585072014e-308,\n"
|
" -2.2250738585072014e-308,\n"
|
||||||
" -1.7976931348623157e+308,\n"
|
" -1.7976931348623157e+308,\n"
|
||||||
" -2.2204460492503131e-16,\n"
|
" -2.2204460492503131e-16,\n"
|
||||||
" -4.9406564584124654e-324,\n"
|
|
||||||
#else
|
#else
|
||||||
" 5e-324,\n"
|
|
||||||
" 2.2250738585072014e-308,\n"
|
" 2.2250738585072014e-308,\n"
|
||||||
" 1.7976931348623157e+308,\n"
|
" 1.7976931348623157e+308,\n"
|
||||||
" 2.220446049250313e-16,\n"
|
" 2.220446049250313e-16,\n"
|
||||||
" 5e-324,\n"
|
|
||||||
" 0,\n"
|
" 0,\n"
|
||||||
" -2.2250738585072014e-308,\n"
|
" -2.2250738585072014e-308,\n"
|
||||||
" -1.7976931348623157e+308,\n"
|
" -1.7976931348623157e+308,\n"
|
||||||
" -2.220446049250313e-16,\n"
|
" -2.220446049250313e-16,\n"
|
||||||
" -5e-324,\n"
|
|
||||||
#endif
|
#endif
|
||||||
" 0,\n"
|
" 0,\n"
|
||||||
" 9007199254740992,\n"
|
" 9007199254740992,\n"
|
||||||
@ -1877,6 +1872,42 @@ void tst_QtJson::toJsonLargeNumericValues()
|
|||||||
QCOMPARE(json, expected);
|
QCOMPARE(json, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QtJson::toJsonDenormalValues()
|
||||||
|
{
|
||||||
|
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
|
||||||
|
QJsonObject object;
|
||||||
|
QJsonArray array;
|
||||||
|
array.append(QJsonValue(5e-324)); // JS Number.MIN_VALUE
|
||||||
|
array.append(QJsonValue(std::numeric_limits<double>::denorm_min()));
|
||||||
|
array.append(QJsonValue(-std::numeric_limits<double>::denorm_min()));
|
||||||
|
object.insert("Array", array);
|
||||||
|
|
||||||
|
QByteArray json = QJsonDocument(object).toJson();
|
||||||
|
QByteArray expected =
|
||||||
|
"{\n"
|
||||||
|
" \"Array\": [\n"
|
||||||
|
#ifdef QT_NO_DOUBLECONVERSION // "shortest" double conversion is not very short then
|
||||||
|
" 4.9406564584124654e-324,\n"
|
||||||
|
" 4.9406564584124654e-324,\n"
|
||||||
|
" -4.9406564584124654e-324\n"
|
||||||
|
#else
|
||||||
|
" 5e-324,\n"
|
||||||
|
" 5e-324,\n"
|
||||||
|
" -5e-324\n"
|
||||||
|
#endif
|
||||||
|
" ]\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
QCOMPARE(json, expected);
|
||||||
|
QJsonDocument doc;
|
||||||
|
doc.setObject(object);
|
||||||
|
json = doc.toJson();
|
||||||
|
QCOMPARE(json, expected);
|
||||||
|
} else {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QtJson::fromJson()
|
void tst_QtJson::fromJson()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -2199,12 +2230,12 @@ void tst_QtJson::parseNumbers()
|
|||||||
QCOMPARE(val.toDouble(), (double)numbers[i].n);
|
QCOMPARE(val.toDouble(), (double)numbers[i].n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
|
||||||
// test number parsing
|
// test number parsing
|
||||||
struct Numbers {
|
struct Numbers {
|
||||||
const char *str;
|
const char *str;
|
||||||
double n;
|
double n;
|
||||||
};
|
};
|
||||||
|
{
|
||||||
Numbers numbers [] = {
|
Numbers numbers [] = {
|
||||||
{ "0", 0 },
|
{ "0", 0 },
|
||||||
{ "1", 1 },
|
{ "1", 1 },
|
||||||
@ -2220,8 +2251,6 @@ void tst_QtJson::parseNumbers()
|
|||||||
{ "1.1e10", 1.1e10 },
|
{ "1.1e10", 1.1e10 },
|
||||||
{ "1.1e308", 1.1e308 },
|
{ "1.1e308", 1.1e308 },
|
||||||
{ "-1.1e308", -1.1e308 },
|
{ "-1.1e308", -1.1e308 },
|
||||||
{ "1.1e-308", 1.1e-308 },
|
|
||||||
{ "-1.1e-308", -1.1e-308 },
|
|
||||||
{ "1.1e+308", 1.1e+308 },
|
{ "1.1e+308", 1.1e+308 },
|
||||||
{ "-1.1e+308", -1.1e+308 },
|
{ "-1.1e+308", -1.1e+308 },
|
||||||
{ "1.e+308", 1.e+308 },
|
{ "1.e+308", 1.e+308 },
|
||||||
@ -2243,6 +2272,31 @@ void tst_QtJson::parseNumbers()
|
|||||||
QCOMPARE(val.toDouble(), numbers[i].n);
|
QCOMPARE(val.toDouble(), numbers[i].n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
|
||||||
|
Numbers numbers [] = {
|
||||||
|
{ "1.1e-308", 1.1e-308 },
|
||||||
|
{ "-1.1e-308", -1.1e-308 }
|
||||||
|
};
|
||||||
|
int size = sizeof(numbers)/sizeof(Numbers);
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
QByteArray json = "[ ";
|
||||||
|
json += numbers[i].str;
|
||||||
|
json += " ]";
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(json);
|
||||||
|
QVERIFY(!doc.isEmpty());
|
||||||
|
QCOMPARE(doc.isArray(), true);
|
||||||
|
QCOMPARE(doc.isObject(), false);
|
||||||
|
QJsonArray array = doc.array();
|
||||||
|
QCOMPARE(array.size(), 1);
|
||||||
|
QJsonValue val = array.at(0);
|
||||||
|
QCOMPARE(val.type(), QJsonValue::Double);
|
||||||
|
QCOMPARE(val.toDouble(), numbers[i].n);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QtJson::parseStrings()
|
void tst_QtJson::parseStrings()
|
||||||
|
@ -1000,10 +1000,24 @@ void tst_QLocale::stringToFloat()
|
|||||||
QLocale locale(locale_name);
|
QLocale locale(locale_name);
|
||||||
QCOMPARE(locale.name(), locale_name);
|
QCOMPARE(locale.name(), locale_name);
|
||||||
|
|
||||||
|
if constexpr (std::numeric_limits<float>::has_denorm != std::denorm_present) {
|
||||||
|
if (qstrcmp(QTest::currentDataTag(), "C float -min") == 0
|
||||||
|
|| qstrcmp(QTest::currentDataTag(), "C float min") == 0)
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
bool ok;
|
bool ok;
|
||||||
float f = locale.toFloat(num_str, &ok);
|
float f = locale.toFloat(num_str, &ok);
|
||||||
QCOMPARE(ok, good);
|
QCOMPARE(ok, good);
|
||||||
|
|
||||||
|
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
|
||||||
|
if (qstrcmp(QTest::currentDataTag(), "C double min") == 0
|
||||||
|
|| qstrcmp(QTest::currentDataTag(), "C double -min") == 0
|
||||||
|
|| qstrcmp(QTest::currentDataTag(), "C tiny") == 0
|
||||||
|
|| qstrcmp(QTest::currentDataTag(), "C -tiny") == 0) {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Make sure result is independent of locale:
|
// Make sure result is independent of locale:
|
||||||
TransientLocale ignoreme(LC_ALL, "ar_SA");
|
TransientLocale ignoreme(LC_ALL, "ar_SA");
|
||||||
|
@ -269,6 +269,13 @@ void tst_QLine::testLength()
|
|||||||
QCOMPARE(l.length(), qreal(length));
|
QCOMPARE(l.length(), qreal(length));
|
||||||
|
|
||||||
l.setLength(lengthToSet);
|
l.setLength(lengthToSet);
|
||||||
|
|
||||||
|
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
|
||||||
|
if (qstrcmp(QTest::currentDataTag(), "[tiny,tiny]->|2| (-tiny/2,-tiny/2)") == 0
|
||||||
|
|| qstrcmp(QTest::currentDataTag(), "[4e-323,5e-324]|1892|") == 0) {
|
||||||
|
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
|
||||||
|
}
|
||||||
|
}
|
||||||
// Scaling tiny values up to big can be imprecise: don't try to test vx, vy
|
// Scaling tiny values up to big can be imprecise: don't try to test vx, vy
|
||||||
if (length > 0 && qFuzzyIsNull(length)) {
|
if (length > 0 && qFuzzyIsNull(length)) {
|
||||||
QVERIFY(l.length() > lengthToSet / 2 && l.length() < lengthToSet * 2);
|
QVERIFY(l.length() > lengthToSet / 2 && l.length() < lengthToSet * 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user