37 ** |
37 ** |
38 ** $QT_END_LICENSE$ |
38 ** $QT_END_LICENSE$ |
39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 // This is included in various .cpp files as a compile test for various scenarios |
|
43 // depending on NO_CAST_* and QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION |
|
44 |
|
45 #if SCENARIO == 1 |
|
46 // this is the "no harm done" version. Only operator% is active, |
|
47 // with NO_CAST * defined |
|
48 #define P % |
|
49 #undef QT_USE_FAST_OPERATOR_PLUS |
|
50 #undef QT_USE_FAST_CONCATENATION |
|
51 #define QT_NO_CAST_FROM_ASCII |
|
52 #define QT_NO_CAST_TO_ASCII |
|
53 #endif |
|
54 |
|
55 |
|
56 #if SCENARIO == 2 |
|
57 // this is the "full" version. Operator+ is replaced by a QStringBuilder |
|
58 // based version |
|
59 // with NO_CAST * defined |
|
60 #define P + |
|
61 #define QT_USE_FAST_OPERATOR_PLUS |
|
62 #define QT_USE_FAST_CONCATENATION |
|
63 #define QT_NO_CAST_FROM_ASCII |
|
64 #define QT_NO_CAST_TO_ASCII |
|
65 #endif |
|
66 |
|
67 #if SCENARIO == 3 |
|
68 // this is the "no harm done" version. Only operator% is active, |
|
69 // with NO_CAST * _not_ defined |
|
70 #define P % |
|
71 #undef QT_USE_FAST_OPERATOR_PLUS |
|
72 #undef QT_USE_FAST_CONCATENATION |
|
73 #undef QT_NO_CAST_FROM_ASCII |
|
74 #undef QT_NO_CAST_TO_ASCII |
|
75 #endif |
|
76 |
|
77 #if SCENARIO == 4 |
|
78 // this is the "full" version. Operator+ is replaced by a QStringBuilder |
|
79 // based version |
|
80 // with NO_CAST * _not_ defined |
|
81 #define P + |
|
82 #define QT_USE_FAST_OPERATOR_PLUS |
|
83 #define QT_USE_FAST_CONCATENATION |
|
84 #undef QT_NO_CAST_FROM_ASCII |
|
85 #undef QT_NO_CAST_TO_ASCII |
|
86 #endif |
|
87 |
|
88 #include <QtTest/QtTest> |
|
89 #include "stringbuilder.h" |
|
90 |
|
91 //TESTED_CLASS=QStringBuilder |
|
92 //TESTED_FILES=qstringbuilder.cpp |
|
93 |
|
94 #define LITERAL "some literal" |
42 #define LITERAL "some literal" |
95 |
43 |
96 void tst_QStringBuilder::scenario() |
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" |
|
46 |
|
47 void runScenario() |
97 { |
48 { |
|
49 // set codec for C strings to 0, enforcing Latin1 |
|
50 QTextCodec::setCodecForCStrings(0); |
|
51 QVERIFY(!QTextCodec::codecForCStrings()); |
|
52 |
98 QLatin1Literal l1literal(LITERAL); |
53 QLatin1Literal l1literal(LITERAL); |
99 QLatin1String l1string(LITERAL); |
54 QLatin1String l1string(LITERAL); |
100 QString string(l1string); |
55 QString string(l1string); |
101 QStringRef stringref(&string, 2, 10); |
56 QStringRef stringref(&string, 2, 10); |
102 QLatin1Char achar('c'); |
57 QLatin1Char achar('c'); |