From 72024fd50cdead8d890886dba32fd81ac54ff3ae Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 9 Jul 2014 14:25:26 +0200 Subject: Reduce repetitive invocations of QFINDTESTDATA. Store the file names in variables instead. Task-number: QTBUG-38890 Change-Id: I65f28bb62674f14aa099e935a9d7a4e9e6e90ba9 Reviewed-by: Joerg Bornemann Reviewed-by: Shawn Rutledge --- tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/io/qtemporaryfile') diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index edf4dd2f00..74220d7f97 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -446,13 +446,15 @@ void tst_QTemporaryFile::rename() void tst_QTemporaryFile::renameFdLeak() { #ifdef Q_OS_UNIX + const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__)); + QVERIFY(!sourceFile.isEmpty()); // Test this on Unix only // Open a bunch of files to force the fd count to go up static const int count = 10; int bunch_of_files[count]; for (int i = 0; i < count; ++i) { - bunch_of_files[i] = ::open(qPrintable(QFINDTESTDATA("tst_qtemporaryfile.cpp")), O_RDONLY); + bunch_of_files[i] = ::open(sourceFile.constData(), O_RDONLY); QVERIFY(bunch_of_files[i] != -1); } @@ -647,8 +649,10 @@ void tst_QTemporaryFile::createNativeFile_data() QTest::addColumn("valid"); QTest::addColumn("content"); - QTest::newRow("nativeFile") << QFINDTESTDATA("resources/test.txt") << (qint64)-1 << false << QByteArray(); - QTest::newRow("nativeFileWithPos") << QFINDTESTDATA("resources/test.txt") << (qint64)5 << false << QByteArray(); + const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); + + QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); + QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test"); QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test"); } -- cgit v1.2.3