tests/auto/qstringbuilder1/stringbuilder.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    42 #define LITERAL "some literal"
    42 #define LITERAL "some literal"
    43 
    43 
    44 // "some literal", but replacing all vocals by their umlauted UTF-8 string :)
    44 // "some literal", but replacing all vocals by their umlauted UTF-8 string :)
    45 #define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l"
    45 #define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l"
    46 
    46 
       
    47 
       
    48 //fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
       
    49 #ifndef QT_USE_FAST_CONCATENATION
       
    50 #define Q %
       
    51 #else
       
    52 #define Q P
       
    53 #endif
       
    54 
    47 void runScenario()
    55 void runScenario()
    48 {
    56 {
    49     // set codec for C strings to 0, enforcing Latin1
    57     // set codec for C strings to 0, enforcing Latin1
    50     QTextCodec::setCodecForCStrings(0);
    58     QTextCodec::setCodecForCStrings(0);
    51     QVERIFY(!QTextCodec::codecForCStrings());
    59     QVERIFY(!QTextCodec::codecForCStrings());
    57     QLatin1Char achar('c');
    65     QLatin1Char achar('c');
    58     QString r2(QLatin1String(LITERAL LITERAL));
    66     QString r2(QLatin1String(LITERAL LITERAL));
    59     QString r;
    67     QString r;
    60     QByteArray ba(LITERAL);
    68     QByteArray ba(LITERAL);
    61 
    69 
    62     r = l1literal P l1literal;
    70     r = l1literal Q l1literal;
    63     QCOMPARE(r, r2);
    71     QCOMPARE(r, r2);
    64     r = string P string;
    72     r = string P string;
    65     QCOMPARE(r, r2);
    73     QCOMPARE(r, r2);
    66     r = stringref P stringref;
    74     r = stringref Q stringref;
    67     QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
    75     QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
    68     r = string P l1literal;
    76     r = string Q l1literal;
    69     QCOMPARE(r, r2);
    77     QCOMPARE(r, r2);
    70     r = string P l1string;
    78     r = string P l1string;
    71     QCOMPARE(r, r2);
    79     QCOMPARE(r, r2);
    72     r = string + achar;
    80     r = string + achar;
    73     QCOMPARE(r, QString(string P achar));
    81     QCOMPARE(r, QString(string P achar));