69 }; |
70 }; |
70 |
71 |
71 void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn) |
72 void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn) |
72 { |
73 { |
73 QFile file(expectedFn); |
74 QFile file(expectedFn); |
74 QVERIFY(file.open(QIODevice::ReadOnly)); |
75 QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); |
75 QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n'); |
76 QStringList expected = QString(file.readAll()).trimmed().split('\n'); |
76 |
77 |
77 int i = 0, ei = expected.size(), gi = actual.size(); |
78 int i = 0, ei = expected.size(), gi = actual.size(); |
78 for (; ; i++) { |
79 for (; ; i++) { |
79 if (i == gi) { |
80 if (i == gi) { |
80 if (i == ei) |
81 if (i == ei) |
208 |
209 |
209 QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string.")); |
210 QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string.")); |
210 QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("This has no translation.")); |
211 QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("This has no translation.")); |
211 } |
212 } |
212 |
213 |
|
214 void tst_lrelease::markuntranslated() |
|
215 { |
|
216 QVERIFY(!QProcess::execute(binDir + "/lrelease -markuntranslated # -idbased testdata/idbased.ts")); |
|
217 |
|
218 QTranslator translator; |
|
219 QVERIFY(translator.load("testdata/idbased.qm")); |
|
220 qApp->installTranslator(&translator); |
|
221 |
|
222 QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string.")); |
|
223 QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("#This has no translation.")); |
|
224 } |
|
225 |
213 void tst_lrelease::dupes() |
226 void tst_lrelease::dupes() |
214 { |
227 { |
215 QProcess proc; |
228 QProcess proc; |
216 proc.start(binDir + "/lrelease testdata/dupes.ts"); |
229 proc.start(binDir + "/lrelease testdata/dupes.ts", QIODevice::ReadWrite | QIODevice::Text); |
217 QVERIFY(proc.waitForFinished()); |
230 QVERIFY(proc.waitForFinished()); |
218 QVERIFY(proc.exitStatus() == QProcess::NormalExit); |
231 QVERIFY(proc.exitStatus() == QProcess::NormalExit); |
219 doCompare(QString(proc.readAllStandardError()).trimmed().remove('\r').split('\n'), "testdata/dupes.errors"); |
232 doCompare(QString(proc.readAllStandardError()).trimmed().split('\n'), "testdata/dupes.errors"); |
220 } |
233 } |
221 |
234 |
222 QTEST_MAIN(tst_lrelease) |
235 QTEST_MAIN(tst_lrelease) |
223 #include "tst_lrelease.moc" |
236 #include "tst_lrelease.moc" |