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

QCOMPARE: not able to display localized text(at test fail)

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 4.7.0
    • Testing: qtestlib
    • None
    • Debian GNU/Linux squeeze, gcc 4.4.5

    • 4a680036c4b52a58b89090657d61fb49a58e1d9a

    Description

      A typical variant of QCOMPARE macro (from the documentation).

       
       void TestQString::toUpper()
       {
           QString str = "!Hello";
           QCOMPARE(str.toUpper(), QString("HELLO"));
       }
      

      In the log appears

       
      FAIL!  : TestQString::toUpper() Compared values are not the same
         Actual (str.toUpper()): !HELLO
         Expected (QString("HELLO")): HELLO
         Loc: [test.cpp(27)]
      

      But QString in real program can be obtained as the result of tested functions and may be localized:

       
       void TestQString::toUpper()
       {
           QString str =some_function();
           QCOMPARE(str, QString("HELLO"));
       }
      

      In the log appears

       
      FAIL!  : TestQString::toUpper() Compared values are not the same
         Actual (str): ?????
         Expected (QString("HELLO")): HELLO
         Loc: [test.cpp(27)]
      

      In my system, I can watch the console localized strings, but deprived of this opportunity. This creates unnecessary hardships and difficult to debug.
      I researched the problem and find function(src/testlib/qtestcase.cpp)

       
      void filter_unprintable(char *str)
      {
          char *idx = str;
          while (*idx) {
              if (((*idx < 0x20 && *idx != '\n' && *idx != '\t') || *idx > 0x7e))
                  *idx = '?';
              ++idx;
          }
      }
      

      It seems the reason for such behavior in this function

      Attachments

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

        Activity

          People

            macadder Jason McDonald
            laborer Sergey Gusarov
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes