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

QCOMPARE: improve diagnostic output for list mismatches

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • None
    • Testing: qtestlib
    • None

    Description

          QStringList a{ u"Hello"_s, u"World"_s };
          QStringList b{ u"Helo"_s, u"Wrld"_s };
          QCOMPARE(a, b);
      

      gives:
      ```
      FAIL! : myTest() Compared lists differ at index 0.
      Actual (a): "Hello"
      Expected (b): "Helo"
      Loc: [/home/tim/dev/...]
      ```

      while this is certainly correct, it would be interesting to see more diagnostic output, e.g. both actual and expected outputs.

      compare the catch2 output for example:

      #include <catch2/catch_test_macros.hpp>
      #include <catch2/catch_session.hpp>
      
      #include <vector>
      
      int main( int argc, char* argv[] ) {
        int result = Catch::Session().run( argc, argv );
        return result;
      }
      TEST_CASE( "myTest" )
      {
          std::vector a{1, 2}, b{2, 3};
          CHECK(a == b);
      }
      
      /app/example.cpp:13: FAILED:
        CHECK( a == b )
      with expansion:
        { 1, 2 } == { 2, 3 }
      

      https://godbolt.org/z/TYnj73314

      Attachments

        Issue Links

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

          Activity

            People

              macadder Jason McDonald
              timblechmann tim blechmann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes