Move old tst_QLocale::negativeZero() to tst_QString::number()
It was more complex than it needed to be and was a test of QString, not of QLocale. This leaves tst_QLocale::negativeZero() available to now test how QLocale handles negative zero. Change-Id: Ic9aae250c29f579e6d60fba8404b38673a3b489f Reviewed-by: Lars Knoll <lars.knoll@qt.io>bb10
parent
47d94dab0f
commit
264ed73052
|
|
@ -59,6 +59,7 @@
|
|||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(QLocale::FormatType)
|
||||
Q_DECLARE_METATYPE(QStringView)
|
||||
|
||||
class tst_QLocale : public QObject
|
||||
{
|
||||
|
|
@ -95,6 +96,7 @@ private slots:
|
|||
void long_long_conversion_extra();
|
||||
void testInfAndNan();
|
||||
void fpExceptions();
|
||||
void negativeZero_data();
|
||||
void negativeZero();
|
||||
void dayOfWeek();
|
||||
void dayOfWeek_data();
|
||||
|
|
@ -1422,13 +1424,29 @@ void tst_QLocale::fpExceptions()
|
|||
#endif
|
||||
}
|
||||
|
||||
void tst_QLocale::negativeZero_data()
|
||||
{
|
||||
QTest::addColumn<QLocale::Language>("language");
|
||||
QTest::addColumn<QLocale::Script>("script");
|
||||
QTest::addColumn<QLocale::Country>("territory");
|
||||
QTest::addColumn<QStringView>("expect");
|
||||
|
||||
QTest::newRow("C")
|
||||
<< QLocale::C << QLocale::AnyScript << QLocale::AnyCountry
|
||||
<< QStringView(u"0");
|
||||
QTest::newRow("Arabic")
|
||||
<< QLocale::Arabic << QLocale::ArabicScript << QLocale::AnyCountry
|
||||
<< QStringView(u"\u0660");
|
||||
}
|
||||
|
||||
void tst_QLocale::negativeZero()
|
||||
{
|
||||
double negativeZero( 0.0 ); // Initialise to zero.
|
||||
uchar *ptr = (uchar *)&negativeZero;
|
||||
ptr[QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 7] = 0x80;
|
||||
QString s = QString::number(negativeZero);
|
||||
QCOMPARE(s, QString("0"));
|
||||
QFETCH(QLocale::Language, language);
|
||||
QFETCH(QLocale::Script, script);
|
||||
QFETCH(QLocale::Country, territory);
|
||||
QFETCH(QStringView, expect);
|
||||
QLocale locale(language, script, territory);
|
||||
QCOMPARE(locale.toString(std::copysign(0.0, -1.0)), expect);
|
||||
}
|
||||
|
||||
void tst_QLocale::dayOfWeek_data()
|
||||
|
|
|
|||
|
|
@ -4927,13 +4927,14 @@ void tst_QString::arg()
|
|||
|
||||
void tst_QString::number()
|
||||
{
|
||||
QCOMPARE( QString::number(int(0)), QLatin1String("0") );
|
||||
QCOMPARE( QString::number((unsigned int)(11)), QLatin1String("11") );
|
||||
QCOMPARE( QString::number(-22L), QLatin1String("-22") );
|
||||
QCOMPARE( QString::number(333UL), QLatin1String("333") );
|
||||
QCOMPARE( QString::number(4.4), QLatin1String("4.4") );
|
||||
QCOMPARE( QString::number(Q_INT64_C(-555)), QLatin1String("-555") );
|
||||
QCOMPARE( QString::number(Q_UINT64_C(6666)), QLatin1String("6666") );
|
||||
QCOMPARE(QString::number(int(0)), QLatin1String("0"));
|
||||
QCOMPARE(QString::number(std::copysign(0.0, -1.0)), QLatin1String("0"));
|
||||
QCOMPARE(QString::number((unsigned int)(11)), QLatin1String("11"));
|
||||
QCOMPARE(QString::number(-22L), QLatin1String("-22"));
|
||||
QCOMPARE(QString::number(333UL), QLatin1String("333"));
|
||||
QCOMPARE(QString::number(4.4), QLatin1String("4.4"));
|
||||
QCOMPARE(QString::number(Q_INT64_C(-555)), QLatin1String("-555"));
|
||||
QCOMPARE(QString::number(Q_UINT64_C(6666)), QLatin1String("6666"));
|
||||
|
||||
#ifndef QT_NO_DOUBLECONVERSION // snprintf_l is too stupid for this
|
||||
QCOMPARE( QString::number(12.05, 'f', 1), QString("12.1") );
|
||||
|
|
|
|||
Loading…
Reference in New Issue