Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-55574

Make QCOMPARE display useful information when comparing two colours fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.10.0 Beta 4
    • 5.0.0
    • Testing: qtestlib
    • None
    • c988a8a28214914d20f4b8858e7f314a51b27507

    Description

      #include <QString>
      #include <QtTest>
      #include <QColor>
      
      class Test : public QObject
      {
          Q_OBJECT
      
      public:
          Test();
      
      private Q_SLOTS:
          void hsl();
          void alpha();
          void invalid();
      };
      
      Test::Test()
      {
      }
      
      void Test::hsl()
      {
          QColor black(Qt::black);
          QColor blackHsl = black.toHsl();
          QCOMPARE(black, blackHsl);
      }
      
      void Test::alpha()
      {
          QColor black(Qt::black);
          QColor transparentBlack = black;
          transparentBlack.setAlpha(0);
          QCOMPARE(black, transparentBlack);
      }
      
      void Test::invalid()
      {
          QColor black(Qt::black);
          QColor invalid;
          QVERIFY(!invalid.isValid());
          QCOMPARE(black, invalid);
      }
      
      QTEST_APPLESS_MAIN(Test)
      
      #include "tst_test.moc"
      
      Starting C:\Users\Mitch\AppData\Local\Temp\untitled3-qt5_7_debug-Debug\debug\tst_test.exe...
      ********* Start testing of Test *********
      Config: Using QtTest library 5.7.0, Qt 5.7.0 (x86_64-little_endian-llp64 shared (dynamic) debug build; by MSVC 2015)
      PASS   : Test::initTestCase()
      FAIL!  : Test::hsl() Compared values are not the same
         Actual   (black)   : #000000
         Expected (blackHsl): #000000
      ..\untitled3\tst_test.cpp(26) : failure location
      FAIL!  : Test::alpha() Compared values are not the same
         Actual   (black)           : #000000
         Expected (transparentBlack): #000000
      ..\untitled3\tst_test.cpp(34) : failure location
      FAIL!  : Test::invalid() Compared values are not the same
         Actual   (black)  : #000000
         Expected (invalid): #000000
      ..\untitled3\tst_test.cpp(42) : failure location
      PASS   : Test::cleanupTestCase()
      Totals: 2 passed, 3 failed, 0 skipped, 0 blacklisted, 4ms
      ********* Finished testing of Test *********
      C:\Users\Mitch\AppData\Local\Temp\untitled3-qt5_7_debug-Debug\debug\tst_test.exe exited with code 3
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes