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

compare() wrongly considers colors as equal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.8.0
    • 5.2.0 Beta1
    • Testing: QuickTest
    • None

    Description

      QtTest's compare() function considers two colors (the QML basic type) as equal when they aren't.

      I am aware that Qt.colorEqual exists (and it works correctly), but I think that this makes it far too easy to write tests that don't catch an error.

      Consider the following test case:

      import QtQuick 2.2
      import QtTest 1.0
      
      Item {
          Rectangle {
              id: black
              color: "#000000"
          }
      
          Rectangle {
              id: white
              color: "#ffffff"
          }
      
          TestCase {
              name: "ColorComparison"
      
              function test_this_should_fail() {
                  compare(black.color, white.color)
              }
      
              function test_this_is_ok() {
                  compare(black.color == white.color, false)
                  compare(Qt.colorEqual(black.color, white.color), false)
              }
          }
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-34878
          # Subject Branch Project Status CR V

          Activity

            People

              shausman Simon Hausmann
              mak Martin Koeleman
              Votes:
              5 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes