#include <QDebug>
#include <QFile>
#include <QTcpSocket>
+#include <QTemporaryDir>
#include <QTextStream>
#include <QTextCodec>
#include <QProcess>
#include "../../../network-settings.h"
-static const char *TestFileName = "testfile";
-
Q_DECLARE_METATYPE(qlonglong)
Q_DECLARE_METATYPE(qulonglong)
Q_DECLARE_METATYPE(QList<int>)
{
Q_OBJECT
+public:
+ tst_QTextStream();
+
public slots:
void initTestCase();
void cleanup();
void generateRealNumbersData(bool for_QString);
void generateStringData(bool for_QString);
void generateRealNumbersDataWrite();
+
+ QTemporaryDir tempDir;
+ QString testFileName;
};
+tst_QTextStream::tst_QTextStream()
+ : tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX")
+{
+}
+
void tst_QTextStream::initTestCase()
{
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
+ testFileName = tempDir.path() + "/testfile";
+
// chdir into the testdata dir and refer to our helper apps with relative paths
QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
QFETCH(QByteArray, data);
QFETCH(QStringList, lines);
- QFile::remove(TestFileName);
- QFile file(TestFileName);
+ QFile::remove(testFileName);
+ QFile file(testFileName);
QVERIFY(file.open(QFile::ReadWrite));
QCOMPARE(file.write(data), qlonglong(data.size()));
QVERIFY(file.flush());
void tst_QTextStream::pos3LargeFile()
{
{
- QFile file(TestFileName);
+ QFile file(testFileName);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out( &file );
// NOTE: The unusual spacing is to ensure non-1-character whitespace.
out << lineString;
// File is automatically flushed and closed on destruction.
}
- QFile file(TestFileName);
+ QFile file(testFileName);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in( &file );
const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
void tst_QTextStream::utf8IncompleteAtBufferBoundary()
{
- QFile::remove(TestFileName);
- QFile data(TestFileName);
+ QFile::remove(testFileName);
+ QFile data(testFileName);
QTextCodec *utf8Codec = QTextCodec::codecForMib(106);
QString lineContents = QString::fromUtf8("\342\200\223" // U+2013 EN DASH