[poppler] 2 commits - qt4/tests
Pino Toscano
pino at kemper.freedesktop.org
Fri Feb 8 16:35:23 PST 2008
qt4/tests/check_dateConversion.cpp | 34 ++++++++++++++++++++++++++++++++++
qt4/tests/check_password.cpp | 31 ++++++++++++++++---------------
2 files changed, 50 insertions(+), 15 deletions(-)
New commits:
commit 2a39932ae35a2716842bd2a1c3d4f9ce6b1e3dd8
Author: Pino Toscano <pino at kde.org>
Date: Sat Feb 9 01:31:20 2008 +0100
Few improvements to the password test.
- QString::fromUtf8() instead of QFile::encodeName() to correctly pass the utf8 filenames
- QVERIFY(!foo) instead of QCOMPARE(foo, false)
- QVERIFY() also the return value of unlock()
diff --git a/qt4/tests/check_password.cpp b/qt4/tests/check_password.cpp
index a6d6819..7bc81b2 100644
--- a/qt4/tests/check_password.cpp
+++ b/qt4/tests/check_password.cpp
@@ -19,9 +19,9 @@ private slots:
void TestPassword::password1()
{
Poppler::Document *doc;
- doc = Poppler::Document::load(QFile::decodeName("../../../test/unittestcases/Gday garçon - open.pdf"), "", QString::fromUtf8("garçon").toLatin1() );
+ doc = Poppler::Document::load(QString::fromUtf8("../../../test/unittestcases/Gday garçon - open.pdf"), "", QString::fromUtf8("garçon").toLatin1() );
QVERIFY( doc );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
@@ -30,11 +30,11 @@ void TestPassword::password1()
void TestPassword::password1a()
{
Poppler::Document *doc;
- doc = Poppler::Document::load(QFile::decodeName("../../../test/unittestcases/Gday garçon - open.pdf") );
+ doc = Poppler::Document::load(QString::fromUtf8("../../../test/unittestcases/Gday garçon - open.pdf") );
QVERIFY( doc );
QVERIFY( doc->isLocked() );
- doc->unlock( "", QString::fromUtf8("garçon").toLatin1() );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->unlock( "", QString::fromUtf8("garçon").toLatin1() ) );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
@@ -42,9 +42,9 @@ void TestPassword::password1a()
void TestPassword::password2()
{
Poppler::Document *doc;
- doc = Poppler::Document::load(QFile::decodeName("../../../test/unittestcases/Gday garçon - owner.pdf"), QString::fromUtf8("garçon").toLatin1(), "" );
+ doc = Poppler::Document::load(QString::fromUtf8("../../../test/unittestcases/Gday garçon - owner.pdf"), QString::fromUtf8("garçon").toLatin1(), "" );
QVERIFY( doc );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
@@ -52,9 +52,9 @@ void TestPassword::password2()
void TestPassword::password2a()
{
Poppler::Document *doc;
- doc = Poppler::Document::load(QFile::decodeName("../../../test/unittestcases/Gday garçon - owner.pdf"), QString::fromUtf8("garçon").toLatin1() );
+ doc = Poppler::Document::load(QString::fromUtf8("../../../test/unittestcases/Gday garçon - owner.pdf"), QString::fromUtf8("garçon").toLatin1() );
QVERIFY( doc );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
@@ -62,10 +62,11 @@ void TestPassword::password2a()
void TestPassword::password2b()
{
Poppler::Document *doc;
- doc = Poppler::Document::load(QFile::decodeName("../../../test/unittestcases/Gday garçon - owner.pdf") );
+ doc = Poppler::Document::load(QString::fromUtf8("../../../test/unittestcases/Gday garçon - owner.pdf") );
QVERIFY( doc );
- doc->unlock( QString::fromUtf8("garçon").toLatin1(), "" );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->isLocked() );
+ QVERIFY( !doc->unlock( QString::fromUtf8("garçon").toLatin1(), "" ) );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
@@ -73,11 +74,11 @@ void TestPassword::password2b()
void TestPassword::password3()
{
Poppler::Document *doc;
- doc = Poppler::Document::load( QFile::decodeName("../../../test/unittestcases/PasswordEncrypted.pdf") );
+ doc = Poppler::Document::load( QString::fromUtf8("../../../test/unittestcases/PasswordEncrypted.pdf") );
QVERIFY( doc );
QVERIFY( doc->isLocked() );
- doc->unlock( "", "password" );
- QCOMPARE( doc->isLocked(), false );
+ QVERIFY( !doc->unlock( "", "password" ) );
+ QVERIFY( !doc->isLocked() );
delete doc;
}
commit cc9c124d4d859b845eebf4ca1e4397870a35fd4e
Author: Pino Toscano <pino at kde.org>
Date: Sat Feb 9 01:09:02 2008 +0100
Add an unit test case for few invalid dates.
diff --git a/qt4/tests/check_dateConversion.cpp b/qt4/tests/check_dateConversion.cpp
index 171712c..c9e2e20 100644
--- a/qt4/tests/check_dateConversion.cpp
+++ b/qt4/tests/check_dateConversion.cpp
@@ -11,6 +11,8 @@ class TestDateConv: public QObject
private slots:
void checkDates_data();
void checkDates();
+ void checkInvalidDates_data();
+ void checkInvalidDates();
};
void TestDateConv::checkDates_data()
@@ -99,6 +101,38 @@ void TestDateConv::checkDates()
QCOMPARE( Poppler::convertDate(input.data()), QDateTime(day, time, Qt::UTC) );
}
+void TestDateConv::checkInvalidDates_data()
+{
+ QTest::addColumn<QByteArray>("input");
+
+ // Null data
+ QTest::newRow("Null data")
+ << QByteArray();
+
+ // Empty data
+ QTest::newRow("Empty data")
+ << QByteArray("");
+
+ // Empty data
+ QTest::newRow("One character")
+ << QByteArray("D");
+
+ // Empty data
+ QTest::newRow("'D:'")
+ << QByteArray("D:");
+
+ // Empty data
+ QTest::newRow("Not a date")
+ << QByteArray("D:IAmNotAValidDate");
+}
+
+void TestDateConv::checkInvalidDates()
+{
+ QFETCH(QByteArray, input);
+
+ QCOMPARE(Poppler::convertDate(input.data()), QDateTime());
+}
+
QTEST_MAIN(TestDateConv)
#include "check_dateConversion.moc"
More information about the poppler
mailing list