Mercurial > trustbridge
diff ui/tests/certlistparsertest.cpp @ 249:6a7eb102716d
Remove code duplication by unifying the certificatelist.
You should now check for isInstallCert to determine wether this
certificate should be installed or removed.
Leaving the getInstallCertificates and getRemoveCertificates
in place for compatibilty would have been easier to keep the
tests stable.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 31 Mar 2014 08:06:17 +0000 |
parents | c05e126b0b9e |
children | ee59ab0eb7ff |
line wrap: on
line diff
--- a/ui/tests/certlistparsertest.cpp Mon Mar 31 08:03:20 2014 +0000 +++ b/ui/tests/certlistparsertest.cpp Mon Mar 31 08:06:17 2014 +0000 @@ -23,8 +23,7 @@ QVERIFY(certList->rawData() == validData.toLatin1()); - const QList<Certificate> instList = certList->getInstallCertificates(); - const QList<Certificate> remoList = certList->getRemoveCertificates(); + const QList<Certificate> cList = certList->getCertificates(); foreach (QString act, validData.split("\r\n")) { if (act.startsWith("I:")) { @@ -37,20 +36,24 @@ } } - foreach (const Certificate& cert, instList) { + int instCnt = 0, + remoCnt = 0; + foreach (const Certificate& cert, cList) { QVERIFY(cert.isValid()); - QVERIFY(instLines.contains(cert.base64Line())); - } - foreach (const Certificate& cert, remoList) { - QVERIFY(cert.isValid()); - QVERIFY(remoLines.contains(cert.base64Line())); + if (cert.isInstallCert()) { + QVERIFY(instLines.contains(cert.base64Line())); + instCnt++; + } else { + QVERIFY(remoLines.contains(cert.base64Line())); + remoCnt++; + } } /* Be variable if test data changes later */ - QVERIFY(instList.size() >= 1); - QVERIFY(remoList.size() >= 1); - QVERIFY(instLines.size() == instList.size()); - QVERIFY(remoLines.size() == remoList.size()); + QVERIFY(instCnt >= 1); + QVERIFY(remoCnt >= 1); + QVERIFY(instLines.size() == instCnt); + QVERIFY(remoLines.size() == remoCnt); /* Check that a default certificate is invalid */ Certificate cert; @@ -58,10 +61,8 @@ certList->readList(fileName.toLocal8Bit().data()); - const QList<Certificate> instList2 = certList->getInstallCertificates(); - const QList<Certificate> remoList2 = certList->getRemoveCertificates(); - QVERIFY(instLines.size() == instList2.size()); - QVERIFY(remoLines.size() == remoList2.size()); + const QList<Certificate> cList2 = certList->getCertificates(); + QVERIFY(instLines.size() + remoLines.size() == cList2.size()); delete certList; }