D20032: Convert string formatting tests to be data driven

Aleix Pol Gonzalez noreply at phabricator.kde.org
Mon Mar 25 11:25:00 GMT 2019


apol added a comment.


  +1 to _data splitting, makes a lot of sense.

INLINE COMMENTS

> propertyinfotest.cpp:71
>  
> -    PropertyInfo bitRate(Property::BitRate);
> -    QCOMPARE(bitRate.formatAsDisplayString(QVariant(128000)), QStringLiteral("128 kbit/s"));
> -    QCOMPARE(bitRate.formatAsDisplayString(QVariant(1350000)), QString(QLocale().toString(1.35) + QStringLiteral(" Mbit/s")));
> -    QCOMPARE(bitRate.formatAsDisplayString(QVariant(14700000)), QString(QLocale().toString(14.7) + QStringLiteral(" Mbit/s")));
> -
> -    PropertyInfo orientation(Property::ImageOrientation);
> -    QCOMPARE(orientation.formatAsDisplayString(QVariant(5)), QStringLiteral("Transposed"));
> -
> -    PropertyInfo flash(Property::PhotoFlash);
> -    QCOMPARE(flash.formatAsDisplayString(QVariant(0x00)), QStringLiteral("No flash"));
> -    QCOMPARE(flash.formatAsDisplayString(QVariant(0x50)), QStringLiteral("No, red-eye reduction"));
> -
> -    PropertyInfo altitude(Property::PhotoGpsAltitude);
> -    QCOMPARE(altitude.formatAsDisplayString(QVariant(1.1)), QString(QLocale().toString(1.1) + QStringLiteral(" m")));
> -
> -    PropertyInfo latitude(Property::PhotoGpsLatitude);
> -    // make tests on windows happy: QChar(0x00B0) = "°"
> -    QCOMPARE(latitude.formatAsDisplayString(QVariant(25)), QString(QLocale().toString(25) + QChar(0x00B0)));
> -
> -    PropertyInfo longitude(Property::PhotoGpsLongitude);
> -    QCOMPARE(longitude.formatAsDisplayString(QVariant(13.5)), QString(QLocale().toString(13.5) + QChar(0x00B0)));
> -
> -    PropertyInfo framerate(Property::FrameRate);
> -    QCOMPARE(framerate.formatAsDisplayString(QVariant(23)), QStringLiteral("23 fps"));
> -    QCOMPARE(framerate.formatAsDisplayString(QVariant(23.976)), QStringLiteral("23.98 fps"));
> -
> -    PropertyInfo aspectRatio(Property::AspectRatio);
> -    QCOMPARE(aspectRatio.formatAsDisplayString(QVariant(1.77778)), QStringLiteral("1.78:1"));
> +    struct {
> +        KFileMetaData::Property::Property property;

Is the struct really necessary?
You can be about as short by calling QTest::addRow directly for each line.

REPOSITORY
  R286 KFileMetaData

REVISION DETAIL
  https://phabricator.kde.org/D20032

To: bruns, #baloo, #frameworks, ngraham, astippich
Cc: apol, kde-frameworks-devel, gennad, domson, ashaposhnikov, michaelh, astippich, spoorun, ngraham, bruns, abrahams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190325/31b07b2f/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list