38 #include <QElapsedTimer>
40 #include <QStringConverter>
42 #include <QTemporaryDir>
43 #include <QTextStream>
44 #if QT_CONFIG(process)
47 #include "../../../network-settings.h"
48 #include <QtTest/private/qemulationdetector_p.h>
72 void readLineFromDevice_data();
73 void readLineFromDevice();
74 void readLineFromString_data();
75 void readLineFromString();
76 void readLineFromTextDevice_data();
77 void readLineFromTextDevice();
78 void readLineUntilNull();
79 void readLineMaxlen_data();
80 void readLineMaxlen();
81 void readLinesFromBufferCRCR();
85 void readAllFromDevice_data();
86 void readAllFromDevice();
87 void readAllFromString_data();
88 void readAllFromString();
89 void readLineFromStringThenChangeString();
95 void QChar_operators_FromDevice_data();
96 void QChar_operators_FromDevice();
97 void char16_t_operators_FromDevice_data();
98 void char16_t_operators_FromDevice();
99 void char_operators_FromDevice_data();
100 void char_operators_FromDevice();
103 void signedShort_read_operator_FromDevice_data();
104 void signedShort_read_operator_FromDevice();
105 void unsignedShort_read_operator_FromDevice_data();
106 void unsignedShort_read_operator_FromDevice();
107 void signedInt_read_operator_FromDevice_data();
108 void signedInt_read_operator_FromDevice();
109 void unsignedInt_read_operator_FromDevice_data();
110 void unsignedInt_read_operator_FromDevice();
111 void qlonglong_read_operator_FromDevice_data();
112 void qlonglong_read_operator_FromDevice();
113 void qulonglong_read_operator_FromDevice_data();
114 void qulonglong_read_operator_FromDevice();
117 void signedShort_write_operator_ToDevice_data();
118 void signedShort_write_operator_ToDevice();
119 void unsignedShort_write_operator_ToDevice_data();
120 void unsignedShort_write_operator_ToDevice();
121 void signedInt_write_operator_ToDevice_data();
122 void signedInt_write_operator_ToDevice();
123 void unsignedInt_write_operator_ToDevice_data();
124 void unsignedInt_write_operator_ToDevice();
125 void qlonglong_write_operator_ToDevice_data();
126 void qlonglong_write_operator_ToDevice();
127 void qulonglong_write_operator_ToDevice_data();
128 void qulonglong_write_operator_ToDevice();
130 void int_read_with_locale_data();
131 void int_read_with_locale();
133 void int_write_with_locale_data();
134 void int_write_with_locale();
137 void float_read_operator_FromDevice_data();
138 void float_read_operator_FromDevice();
139 void double_read_operator_FromDevice_data();
140 void double_read_operator_FromDevice();
143 void float_write_operator_ToDevice_data();
144 void float_write_operator_ToDevice();
145 void double_write_operator_ToDevice_data();
146 void double_write_operator_ToDevice();
148 void double_write_with_flags_data();
149 void double_write_with_flags();
151 void double_write_with_precision_data();
152 void double_write_with_precision();
155 void charPtr_read_operator_FromDevice_data();
156 void charPtr_read_operator_FromDevice();
157 void stringRef_read_operator_FromDevice_data();
158 void stringRef_read_operator_FromDevice();
159 void byteArray_read_operator_FromDevice_data();
160 void byteArray_read_operator_FromDevice();
163 void string_write_operator_ToDevice_data();
164 void string_write_operator_ToDevice();
165 void latin1String_write_operator_ToDevice();
166 void stringref_write_operator_ToDevice();
167 void stringview_write_operator_ToDevice();
170 void skipWhiteSpace_data();
171 void skipWhiteSpace();
172 void lineCount_data();
181 void zeroTermination();
182 void ws_manipulator();
183 void stillOpenWhenAtEnd();
184 void readNewlines_data();
189 void pos3LargeFile();
191 void readAllFromStdin();
192 void readLineFromStdin();
198 void numeralCase_data();
201 void utf8IncompleteAtBufferBoundary_data();
202 void utf8IncompleteAtBufferBoundary();
203 void writeSeekWriteNoBOM();
206 void status_real_read_data();
207 void status_real_read();
208 void status_integer_read();
209 void status_word_read();
210 void status_write_error();
217 void manipulators_data();
222 void readBomSeekBackReadBomAgain();
225 void alignAccountingStyle();
228 void textModeOnEmptyRead();
231 void generateLineData(
bool for_QString);
232 void generateAllData(
bool for_QString);
233 void generateOperatorCharData(
bool for_QString);
234 void generateNaturalNumbersData(
bool for_QString);
235 void generateRealNumbersData(
bool for_QString);
236 void generateStringData(
bool for_QString);
237 void generateRealNumbersDataWrite();
241 #ifdef BUILTIN_TESTDATA
244 const QString m_rfc3261FilePath;
255 : tempDir(
QDir::tempPath() + "/tst_qtextstream.XXXXXX")
265 testFileName = tempDir.
path() +
"/testfile";
267 #ifdef BUILTIN_TESTDATA
278 void tst_QTextStream::getSetCheck()
398 #ifdef BUILTIN_TESTDATA
404 void tst_QTextStream::construction()
419 void tst_QTextStream::generateLineData(
bool for_QString)
421 QTest::addColumn<QByteArray>(
"data");
422 QTest::addColumn<QStringList>(
"lines");
445 "\x66\x67\x65\x0a", 11)
466 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
467 "\x00\xe5\x00\x67\x00\x65\x00\x0a", 18)
471 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
472 "\xe5\x00\x67\x00\x65\x00\x0a\x00", 18)
478 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
479 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
480 "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26)
484 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
485 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
486 "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
492 "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a"
493 "\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a", 36)
497 "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00"
498 "\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00", 36)
510 void tst_QTextStream::readLineFromDevice_data()
512 generateLineData(
false);
516 void tst_QTextStream::readLineFromDevice()
537 void tst_QTextStream::readLineMaxlen_data()
539 QTest::addColumn<QString>(
"input");
540 QTest::addColumn<QStringList>(
"lines");
558 <<
QString::fromUtf8(
"\341\233\222\341\233\226\341\232\251\341\232\271\341\232\242\341\233\232\341\232\240\n")
564 void tst_QTextStream::readLineMaxlen()
568 for (
int i = 0;
i < 2; ++
i) {
569 bool useDevice = (
i == 1);
592 void tst_QTextStream::readLinesFromBufferCRCR()
598 for (
int i = 0;
i < 10000; ++
i)
627 void tst_QTextStream::readLineInto()
634 ts.readLineInto(&
line);
637 ts.readLineInto(
nullptr, 0);
639 ts.readLineInto(&
line);
652 while (ts.readLineInto(&
line)) {
657 line =
"Test string";
660 ts.setDevice(&errorDevice);
667 void tst_QTextStream::readLineFromString_data()
669 generateLineData(
true);
673 void tst_QTextStream::readLineFromString()
689 void tst_QTextStream::readLineFromStringThenChangeString()
692 QString second =
"Second string";
704 void tst_QTextStream::setDevice()
721 stream.setDevice(&bufferNew);
727 void tst_QTextStream::readLineFromTextDevice_data()
729 generateLineData(
false);
733 void tst_QTextStream::readLineFromTextDevice()
738 for (
int i = 0;
i < 8; ++
i) {
775 void tst_QTextStream::generateAllData(
bool for_QString)
777 QTest::addColumn<QByteArray>(
"input");
778 QTest::addColumn<QString>(
"output");
812 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
813 "\x00\xe5\x00\x67\x00\x65\x00\x0a", 18)
817 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
818 "\xe5\x00\x67\x00\x65\x00\x0a\x00", 18)
824 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
825 "\x00\xe5\x00\x67\x00\x65\x00\x0a"
826 "\x00\xe5\x00\x67\x00\x65\x00\x0a", 26)
830 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
831 "\xe5\x00\x67\x00\x65\x00\x0a\x00"
832 "\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
838 void tst_QTextStream::readLineUntilNull()
844 for (
int i = 0;
i < 15066; ++
i) {
854 void tst_QTextStream::readAllFromDevice_data()
856 generateAllData(
false);
860 void tst_QTextStream::readAllFromDevice()
873 void tst_QTextStream::readAllFromString_data()
875 generateAllData(
true);
879 void tst_QTextStream::readAllFromString()
891 void tst_QTextStream::skipWhiteSpace_data()
893 QTest::addColumn<QByteArray>(
"input");
894 QTest::addColumn<QChar>(
"output");
918 void tst_QTextStream::skipWhiteSpace()
936 stream2.skipWhiteSpace();
944 void tst_QTextStream::lineCount_data()
946 QTest::addColumn<QByteArray>(
"data");
947 QTest::addColumn<int>(
"lineCount");
964 void tst_QTextStream::lineCount()
974 while (!lineReader.atEnd()) {
995 void tst_QTextStream::performance()
1001 const char * readMethods[
N] = {
1002 "QFile::readLine()",
1003 "QTextStream::readLine()",
1004 "QTextStream::readLine(QString *)"
1006 int elapsed[
N] = {0, 0, 0};
1018 elapsed[0] = stopWatch.
elapsed();
1022 QFile file2(m_rfc3261FilePath);
1026 while (!
stream.atEnd()) {
1031 elapsed[1] = stopWatch.
elapsed();
1035 QFile file3(m_rfc3261FilePath);
1040 while (stream2.readLineInto(&
line))
1043 elapsed[2] = stopWatch.
elapsed();
1048 for (
int i = 0;
i <
N;
i++) {
1049 qDebug(
"%s used %.3f seconds to read the file", readMethods[
i],
1050 elapsed[
i] / 1000.0);
1053 int idx[
N] = {0, 1, 2};
1056 for (
int i = 0;
i <
N-1;
i++) {
1059 qDebug(
"Reading by %s is %.2fx faster than by %s",
1061 double(elapsed[i2]) /
double(elapsed[i1]),
1067 void tst_QTextStream::hexTest_data()
1069 QTest::addColumn<qlonglong>(
"number");
1070 QTest::addColumn<QByteArray>(
"data");
1096 void tst_QTextStream::hexTest()
1110 void tst_QTextStream::binTest_data()
1112 QTest::addColumn<int>(
"number");
1113 QTest::addColumn<QByteArray>(
"data");
1126 void tst_QTextStream::binTest()
1140 void tst_QTextStream::octTest_data()
1142 QTest::addColumn<int>(
"number");
1143 QTest::addColumn<QByteArray>(
"data");
1149 void tst_QTextStream::octTest()
1163 void tst_QTextStream::zeroTermination()
1180 void tst_QTextStream::ws_manipulator()
1207 void tst_QTextStream::stillOpenWhenAtEnd()
1213 while (!
stream.readLine().isNull()) {}
1216 #ifdef QT_TEST_SERVER
1218 QSKIP(
"No network test server available");
1220 if (!QtNetworkSettings::verifyTestNetworkSettings())
1221 QSKIP(
"No network test server available");
1229 while (!stream2.readLine().isNull()) {}
1234 void tst_QTextStream::readNewlines_data()
1236 QTest::addColumn<QByteArray>(
"input");
1237 QTest::addColumn<QString>(
"output");
1248 void tst_QTextStream::readNewlines()
1260 void tst_QTextStream::seek()
1272 for (
int i = 0;
i < 4; ++
i) {
1277 for (
int i = 0;
i < 4; ++
i) {
1295 for (
int i = 0;
i < 4; ++
i) {
1300 for (
int i = 0;
i < 4; ++
i) {
1301 stream2.seek(4 -
i);
1308 void tst_QTextStream::pos()
1387 void tst_QTextStream::pos2()
1425 void tst_QTextStream::pos3LargeFile()
1427 if (QTestPrivate::isRunningArmOnX86())
1428 QSKIP(
"Running QTextStream::pos() in tight loop is too slow on emulator");
1435 QString lineString =
" 0 1 2\t3 4\t \t5 6 7 8 9 \n";
1437 const int NbLines = (50*1024) / lineString.
length() + 1;
1445 const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
1449 for (
int i = 0;
i < 10; ++
i ) {
1463 void tst_QTextStream::readStdin()
1465 #if !QT_CONFIG(process)
1466 QSKIP(
"No qprocess support", SkipAll);
1468 QProcess stdinProcess;
1469 stdinProcess.start(
"stdinProcess/stdinProcess");
1470 stdinProcess.setReadChannel(QProcess::StandardError);
1477 stdinProcess.closeWriteChannel();
1479 QVERIFY(stdinProcess.waitForFinished(5000));
1490 void tst_QTextStream::readAllFromStdin()
1492 #if !QT_CONFIG(process)
1493 QSKIP(
"No qprocess support", SkipAll);
1495 QProcess stdinProcess;
1497 stdinProcess.setReadChannel(QProcess::StandardError);
1503 stdinProcess.closeWriteChannel();
1505 QVERIFY(stdinProcess.waitForFinished(5000));
1511 void tst_QTextStream::readLineFromStdin()
1513 #if !QT_CONFIG(process)
1514 QSKIP(
"No qprocess support", SkipAll);
1516 QProcess stdinProcess;
1518 stdinProcess.setReadChannel(QProcess::StandardError);
1520 stdinProcess.write(
"abc\n");
1521 QVERIFY(stdinProcess.waitForReadyRead(5000));
1524 stdinProcess.write(
"def\n");
1525 QVERIFY(stdinProcess.waitForReadyRead(5000));
1528 stdinProcess.closeWriteChannel();
1530 QVERIFY(stdinProcess.waitForFinished(5000));
1535 void tst_QTextStream::read()
1563 for (
int i = 0;
i < 16384 / 8; ++
i)
1577 void tst_QTextStream::qbool()
1586 void tst_QTextStream::forcePoint()
1607 void tst_QTextStream::forceSign()
1616 void tst_QTextStream::read0d0d0a()
1635 void tst_QTextStream::numeralCase_data()
1647 QTest::addColumn<QTextStreamFunction>(
"func1");
1648 QTest::addColumn<QTextStreamFunction>(
"func2");
1649 QTest::addColumn<QTextStreamFunction>(
"func3");
1650 QTest::addColumn<QTextStreamFunction>(
"func4");
1651 QTest::addColumn<int>(
"value");
1652 QTest::addColumn<QString>(
"expected");
1653 QTest::newRow(
"dec 1") << noop_ << noop_ << noop_ << noop_ << 31 <<
"31";
1682 void tst_QTextStream::numeralCase()
1693 stream << func1 << func2 << func3 << func4 <<
value;
1698 void tst_QTextStream::nanInf()
1702 QString str(
"nan NAN nAn +nan +NAN +nAn -nan -NAN -nAn"
1703 " inf INF iNf +inf +INF +iNf -inf -INF -iNf");
1760 void tst_QTextStream::utf8IncompleteAtBufferBoundary_data()
1762 QTest::addColumn<bool>(
"useLocale");
1771 void tst_QTextStream::utf8IncompleteAtBufferBoundary()
1789 for (
int i = 0;
i < 1000; ++
i) {
1809 }
while (!
in.atEnd());
1816 void tst_QTextStream::writeSeekWriteNoBOM()
1833 QCOMPARE(
out.buffer().constData(),
"Size=0000000000\nVersion=14\nblah blah blah\n");
1844 QCOMPARE(
out.buffer().constData(),
"Size=0000000042\nVersion=14\nblah blah blah\n");
1868 void tst_QTextStream::generateOperatorCharData(
bool for_QString)
1870 QTest::addColumn<QByteArray>(
"input");
1871 QTest::addColumn<QChar>(
"qchar_output");
1872 QTest::addColumn<char>(
"char_output");
1873 QTest::addColumn<QByteArray>(
"write_output");
1891 void tst_QTextStream::QChar_operators_FromDevice_data()
1893 generateOperatorCharData(
false);
1897 void tst_QTextStream::QChar_operators_FromDevice()
1916 writeStream << qchar_output;
1917 writeStream.flush();
1924 void tst_QTextStream::char16_t_operators_FromDevice_data()
1926 generateOperatorCharData(
false);
1930 void tst_QTextStream::char16_t_operators_FromDevice()
1934 const char16_t char16_t_output = qchar_output.unicode();
1941 writeStream << char16_t_output;
1942 writeStream.flush();
1949 void tst_QTextStream::char_operators_FromDevice_data()
1951 generateOperatorCharData(
false);
1955 void tst_QTextStream::char_operators_FromDevice()
1958 QFETCH(
char, char_output);
1974 writeStream << char_output;
1975 writeStream.flush();
1982 void tst_QTextStream::generateNaturalNumbersData(
bool for_QString)
1984 QTest::addColumn<QByteArray>(
"input");
1985 QTest::addColumn<qulonglong>(
"output");
2067 "\x00\x30\x00\x78\x00\x64\x00\x65\x00\x61\x00\x64\x00\x62\x00\x65\x00\x65\x00\x66", 22)
2072 "\x30\x00\x78\x00\x64\x00\x65\x00\x61\x00\x64\x00\x62\x00\x65\x00\x65\x00\x66\x00", 22)
2078 #define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR_TEST(texttype, type) \
2079 void tst_QTextStream:: texttype##_read_operator_FromDevice_data() \
2080 { generateNaturalNumbersData(false); } \
2081 void tst_QTextStream:: texttype##_read_operator_FromDevice() \
2083 QFETCH(QByteArray, input); \
2084 QFETCH(qulonglong, output); \
2086 QTextStream stream(&input); \
2088 QCOMPARE(sh, (type)output); \
2099 void tst_QTextStream::generateRealNumbersData(
bool for_QString)
2101 QTest::addColumn<QByteArray>(
"input");
2102 QTest::addColumn<double>(
"output");
2126 #define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR_TEST(texttype, type) \
2127 void tst_QTextStream:: texttype##_read_operator_FromDevice_data() \
2128 { generateRealNumbersData(false); } \
2129 void tst_QTextStream:: texttype##_read_operator_FromDevice() \
2131 QFETCH(QByteArray, input); \
2132 QFETCH(double, output); \
2134 QTextStream stream(&input); \
2136 QCOMPARE(sh, (type)output); \
2143 void tst_QTextStream::generateStringData(
bool for_QString)
2145 QTest::addColumn<QByteArray>(
"input");
2146 QTest::addColumn<QByteArray>(
"array_output");
2147 QTest::addColumn<QString>(
"string_output");
2167 void tst_QTextStream::charPtr_read_operator_FromDevice_data()
2169 generateStringData(
false);
2173 void tst_QTextStream::charPtr_read_operator_FromDevice()
2182 stream.setAutoDetectUnicode(
true);
2187 QCOMPARE((
const char *)
buf, array_output.constData());
2191 void tst_QTextStream::stringRef_read_operator_FromDevice_data()
2193 generateStringData(
false);
2197 void tst_QTextStream::stringRef_read_operator_FromDevice()
2206 stream.setAutoDetectUnicode(
true);
2215 void tst_QTextStream::byteArray_read_operator_FromDevice_data()
2217 generateStringData(
false);
2221 void tst_QTextStream::byteArray_read_operator_FromDevice()
2230 stream.setAutoDetectUnicode(
true);
2239 #define IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(texttype, type) \
2240 void tst_QTextStream:: texttype##_write_operator_ToDevice() \
2242 QFETCH(qulonglong, number); \
2243 QFETCH(QByteArray, data); \
2244 QFETCH(QByteArray, dataWithSeparators); \
2247 buffer.open(QBuffer::WriteOnly); \
2248 QTextStream stream(&buffer); \
2249 stream.setLocale(QLocale::c()); \
2250 stream << (type)number; \
2252 QCOMPARE(buffer.data().constData(), data.constData()); \
2254 QLocale locale("en-US"); \
2255 buffer.reset(); buffer.buffer().clear(); \
2256 stream.setLocale(locale); \
2257 stream << (type)number; \
2259 QCOMPARE(buffer.data(), dataWithSeparators); \
2261 locale.setNumberOptions(QLocale::OmitGroupSeparator); \
2262 buffer.reset(); buffer.buffer().clear(); \
2263 stream.setLocale(locale); \
2264 stream << (type)number; \
2266 QCOMPARE(buffer.data().constData(), data.constData()); \
2268 locale = QLocale("de-DE"); \
2269 buffer.reset(); buffer.buffer().clear(); \
2270 stream.setLocale(locale); \
2271 stream << (type)number; \
2273 QCOMPARE(buffer.data(), dataWithSeparators.replace(',', '.')); \
2277 void tst_QTextStream::signedShort_write_operator_ToDevice_data()
2279 QTest::addColumn<qulonglong>(
"number");
2280 QTest::addColumn<QByteArray>(
"data");
2281 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2297 void tst_QTextStream::unsignedShort_write_operator_ToDevice_data()
2299 QTest::addColumn<qulonglong>(
"number");
2300 QTest::addColumn<QByteArray>(
"data");
2301 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2317 void tst_QTextStream::signedInt_write_operator_ToDevice_data()
2319 QTest::addColumn<qulonglong>(
"number");
2320 QTest::addColumn<QByteArray>(
"data");
2321 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2343 void tst_QTextStream::unsignedInt_write_operator_ToDevice_data()
2345 QTest::addColumn<qulonglong>(
"number");
2346 QTest::addColumn<QByteArray>(
"data");
2347 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2369 void tst_QTextStream::qlonglong_write_operator_ToDevice_data()
2371 QTest::addColumn<qulonglong>(
"number");
2372 QTest::addColumn<QByteArray>(
"data");
2373 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2399 void tst_QTextStream::qulonglong_write_operator_ToDevice_data()
2401 QTest::addColumn<qulonglong>(
"number");
2402 QTest::addColumn<QByteArray>(
"data");
2403 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2430 void tst_QTextStream::generateRealNumbersDataWrite()
2432 QTest::addColumn<double>(
"number");
2433 QTest::addColumn<QByteArray>(
"data");
2434 QTest::addColumn<QByteArray>(
"dataWithSeparators");
2445 #define IMPLEMENT_STREAM_LEFT_REAL_OPERATOR_TEST(texttype, type) \
2446 void tst_QTextStream:: texttype##_write_operator_ToDevice_data() \
2447 { generateRealNumbersDataWrite(); } \
2448 void tst_QTextStream:: texttype##_write_operator_ToDevice() \
2450 QFETCH(double, number); \
2451 QFETCH(QByteArray, data); \
2452 QFETCH(QByteArray, dataWithSeparators); \
2455 buffer.open(QBuffer::WriteOnly); \
2456 QTextStream stream(&buffer); \
2457 stream.setLocale(QLocale::c()); \
2458 float f = (float)number; \
2461 QCOMPARE(buffer.data().constData(), data.constData()); \
2464 stream.setLocale(QLocale("en-US")); \
2467 QCOMPARE(buffer.data(), dataWithSeparators); \
2474 void tst_QTextStream::string_write_operator_ToDevice_data()
2476 QTest::addColumn<QByteArray>(
"bytedata");
2477 QTest::addColumn<QString>(
"stringdata");
2478 QTest::addColumn<QByteArray>(
"result");
2484 <<
QString(
"a cow jumped over the moon")
2497 void tst_QTextStream::string_write_operator_ToDevice()
2509 stream.setAutoDetectUnicode(
true);
2511 stream << bytedata.constData();
2521 stream.setAutoDetectUnicode(
true);
2533 stream.setAutoDetectUnicode(
true);
2541 void tst_QTextStream::latin1String_write_operator_ToDevice()
2547 stream.setAutoDetectUnicode(
true);
2552 QCOMPARE(
buf.buffer().constData(),
"No explicit lengthExplicit length");
2555 void tst_QTextStream::stringref_write_operator_ToDevice()
2561 stream.setAutoDetectUnicode(
true);
2563 const QStringView expected =
u"No explicit lengthExplicit length";
2568 QCOMPARE(
buf.buffer().constData(),
"No explicit lengthExplicit length");
2571 void tst_QTextStream::stringview_write_operator_ToDevice()
2579 QCOMPARE(
buf.buffer().constData(),
"expectedStringView");
2583 void tst_QTextStream::useCase1()
2592 stream.setAutoDetectUnicode(
true);
2607 stream.setAutoDetectUnicode(
true);
2620 void tst_QTextStream::useCase2()
2628 stream.setAutoDetectUnicode(
true);
2645 stream2.setAutoDetectUnicode(
true);
2657 void tst_QTextStream::manipulators_data()
2659 QTest::addColumn<int>(
"base");
2660 QTest::addColumn<int>(
"alignFlag");
2661 QTest::addColumn<int>(
"numberFlag");
2662 QTest::addColumn<int>(
"width");
2663 QTest::addColumn<double>(
"realNumber");
2664 QTest::addColumn<int>(
"intNumber");
2665 QTest::addColumn<QString>(
"textData");
2666 QTest::addColumn<QByteArray>(
"result");
2678 void tst_QTextStream::manipulators()
2684 QFETCH(
double, realNumber);
2694 stream.setAutoDetectUnicode(
true);
2708 void tst_QTextStream::generateBOM()
2739 void tst_QTextStream::readBomSeekBackReadBomAgain()
2759 void tst_QTextStream::status_real_read_data()
2761 QTest::addColumn<QString>(
"input");
2762 QTest::addColumn<double>(
"expected_f");
2763 QTest::addColumn<QString>(
"expected_w");
2764 QTest::addColumn<QList<int> >(
"results");
2775 void tst_QTextStream::status_real_read()
2778 QFETCH(
double, expected_f);
2799 void tst_QTextStream::status_integer_read()
2817 void tst_QTextStream::status_word_read()
2838 void tst_QTextStream::status_write_error()
2856 fb.setLocked(
false);
2857 fs <<
"can't do that";
2863 void tst_QTextStream::alignAccountingStyle()
2906 void tst_QTextStream::setEncoding()
2918 void tst_QTextStream::double_write_with_flags_data()
2920 QTest::addColumn<double>(
"number");
2921 QTest::addColumn<QString>(
"output");
2922 QTest::addColumn<int>(
"numberFlags");
2923 QTest::addColumn<int>(
"realNumberNotation");
2938 void tst_QTextStream::double_write_with_flags()
2942 QFETCH(
int, numberFlags);
2943 QFETCH(
int, realNumberNotation);
2949 if (realNumberNotation)
2955 void tst_QTextStream::double_write_with_precision_data()
2957 QTest::addColumn<int>(
"precision");
2958 QTest::addColumn<double>(
"value");
2959 QTest::addColumn<QString>(
"result");
2973 void tst_QTextStream::double_write_with_precision()
2986 void tst_QTextStream::int_read_with_locale_data()
2988 QTest::addColumn<QString>(
"locale");
2989 QTest::addColumn<QString>(
"input");
2990 QTest::addColumn<int>(
"output");
3005 void tst_QTextStream::int_read_with_locale()
3018 void tst_QTextStream::int_write_with_locale_data()
3020 QTest::addColumn<QString>(
"locale");
3021 QTest::addColumn<int>(
"numberFlags");
3022 QTest::addColumn<int>(
"input");
3023 QTest::addColumn<QString>(
"output");
3034 void tst_QTextStream::int_write_with_locale()
3037 QFETCH(
int, numberFlags);
3045 stream.setNumberFlags(QTextStream::NumberFlags(numberFlags));
3050 void tst_QTextStream::textModeOnEmptyRead()
3066 #include "tst_qtextstream.moc"
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
qint64 readData(char *data, qint64 maxlen) override
qint64 writeData(const char *data, qint64 len) override
FakeBuffer(bool locked=false)
void setLocked(bool locked)
qint64 writeData(const char *c, qint64 i) override
bool waitForReadyRead(int msecs=30000) override
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol)
The QBuffer class provides a QIODevice interface for a QByteArray.
qint64 writeData(const char *data, qint64 len) override
bool open(OpenMode openMode) override
The QByteArray class provides an array of bytes.
qsizetype size() const noexcept
const char * constData() const noexcept
The QChar class provides a 16-bit Unicode character.
static QCoreApplication * instance()
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
static QString applicationDirPath()
The QDir class provides access to directory structures and their contents.
static bool setCurrent(const QString &path)
The QElapsedTimer class provides a fast way to calculate elapsed times.
qint64 elapsed() const noexcept
qint64 restart() noexcept
qint64 pos() const override
bool seek(qint64 offset) override
bool atEnd() const override
The QFile class provides an interface for reading from and writing to files.
bool open(OpenMode flags) override
qint64 size() const override
The QFileInfo class provides system-independent file information.
QString absolutePath() const
The QIODevice class is the base interface class of all I/O devices in Qt.
virtual bool open(QIODeviceBase::OpenMode mode)
qint64 readLine(char *data, qint64 maxlen)
qint64 write(const char *data, qint64 len)
QString errorString() const
bool isTextModeEnabled() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
const_reference at(qsizetype i) const noexcept
The QObject class is the base class of all Qt objects.
The QString class provides a Unicode character string.
QByteArray toLatin1() const &
void reserve(qsizetype size)
static QString fromLatin1(QByteArrayView ba)
QString rightJustified(qsizetype width, QChar fill=QLatin1Char(' '), bool trunc=false) const
static QString fromUtf8(QByteArrayView utf8)
qsizetype capacity() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString number(int, int base=10)
QString trimmed() const &
The QStringList class provides a list of strings.
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
constexpr QStringView left(qsizetype n) const noexcept
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
The QTcpSocket class provides a TCP socket.
The QTemporaryDir class creates a unique directory for temporary use.
QString errorString() const
The QTextStream class provides a convenient interface for reading and writing text.
void setStatus(Status status)
bool autoDetectUnicode() const
void setRealNumberPrecision(int precision)
void setRealNumberNotation(RealNumberNotation notation)
int realNumberPrecision() const
void setEncoding(QStringConverter::Encoding encoding)
void setPadChar(QChar ch)
QIODevice * device() const
void setGenerateByteOrderMark(bool generate)
FieldAlignment fieldAlignment() const
NumberFlags numberFlags() const
void setIntegerBase(int base)
RealNumberNotation realNumberNotation() const
void setFieldAlignment(FieldAlignment alignment)
bool generateByteOrderMark() const
void setAutoDetectUnicode(bool enabled)
void setFieldWidth(int width)
QStringConverter::Encoding encoding() const
void setNumberFlags(NumberFlags flags)
void setDevice(QIODevice *device)
static QString imapServerName()
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message)
Q_TESTLIB_EXPORT const char * currentDataTag()
QTextStream & flush(QTextStream &stream)
QTextStream & hex(QTextStream &stream)
QTextStream & uppercasebase(QTextStream &stream)
QTextStream & bin(QTextStream &stream)
QTextStream & showbase(QTextStream &stream)
QTextStream & lowercasebase(QTextStream &stream)
QTextStream & uppercasedigits(QTextStream &stream)
QTextStream & bom(QTextStream &stream)
QTextStream & oct(QTextStream &stream)
QTextStream & lowercasedigits(QTextStream &stream)
QTextStream & ws(QTextStream &stream)
QTextStream & fixed(QTextStream &stream)
QTextStream & forcesign(QTextStream &stream)
QTextStream & forcepoint(QTextStream &stream)
QTextStream & endl(QTextStream &stream)
QTextStream & scientific(QTextStream &stream)
QTextStream & noop(QTextStream &s)
QList< QString > QStringList
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
bool qIsNaN(qfloat16 f) noexcept
bool qIsInf(qfloat16 f) noexcept
unsigned long long quint64
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf()
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN()
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLenum input
GLenum GLint GLint * precision
#define QStringLiteral(str)
#define QTEST_MAIN(TestObject)
#define QSKIP(statement,...)
#define QFETCH(Type, name)
#define QEXTRACTTESTDATA(resourcePath)
#define QVERIFY(statement)
#define QFINDTESTDATA(basepath)
#define QVERIFY2(statement, description)
QTextStream &(* QTextStreamFunction)(QTextStream &)
QTextStream out(stdout)
[7]
bool operator()(const int i1, const int i2)
CompareIndicesForArray(int *array)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
#define IMPLEMENT_STREAM_RIGHT_INT_OPERATOR_TEST(texttype, type)
#define IMPLEMENT_STREAM_LEFT_REAL_OPERATOR_TEST(texttype, type)
#define IMPLEMENT_STREAM_RIGHT_REAL_OPERATOR_TEST(texttype, type)
#define IMPLEMENT_STREAM_LEFT_INT_OPERATOR_TEST(texttype, type)
Q_DECLARE_METATYPE(QTextStreamFunction)