Mercurial > trustbridge
comparison ui/tests/certlistparsertest.cpp @ 26:cbd57d767dfa
Move layout around. Restructure CMakeLists
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 11 Mar 2014 19:00:35 +0100 |
parents | tests/certlistparsertest.cpp@2ad9a96518e3 |
children | 37fc66967517 |
comparison
equal
deleted
inserted
replaced
25:92108a2120f1 | 26:cbd57d767dfa |
---|---|
1 #include "certlistparsertest.h" | |
2 #include "certificatelist.h" | |
3 | |
4 #include <QDebug> | |
5 | |
6 | |
7 void CertListTest::testInvalidSig() | |
8 { | |
9 const char *fname = "list-invalid-signed.txt"; | |
10 CertificateList *certList = testWithFile(fname); | |
11 QCOMPARE (certList->getStatus(), InvalidSignature); | |
12 delete certList; | |
13 } | |
14 | |
15 void verifyInvalidFile(const char *fName) { | |
16 CertificateList *certList = new CertificateList(fName); | |
17 QVERIFY (certList->getStatus() != Valid); | |
18 delete certList; | |
19 } | |
20 | |
21 void CertListTest::testInvalidFileNames() | |
22 { | |
23 verifyInvalidFile("/dev/random"); | |
24 verifyInvalidFile("/tmp/"); | |
25 verifyInvalidFile(NULL); | |
26 verifyInvalidFile("ä"); | |
27 verifyInvalidFile("💩 "); | |
28 } | |
29 | |
30 void CertListTest::testGarbage() | |
31 { | |
32 const char *fname = "random_500KB"; | |
33 CertificateList *certList = testWithFile(fname); | |
34 QCOMPARE (certList->getStatus(), InvalidFormat); | |
35 delete certList; | |
36 } | |
37 | |
38 void CertListTest::testTooLarge() | |
39 { | |
40 const char *fname = "random_2MB"; | |
41 CertificateList *certList = testWithFile(fname); | |
42 QCOMPARE (certList->getStatus(), TooLarge); | |
43 QVERIFY (!certList->isValid()); | |
44 delete certList; | |
45 } | |
46 | |
47 void CertListTest::testValidList() | |
48 { | |
49 const char *fname = "list-valid-signed.txt"; | |
50 CertificateList *certList = testWithFile(fname); | |
51 QCOMPARE (certList->getStatus(), Valid); | |
52 QVERIFY (certList->isValid()); | |
53 delete certList; | |
54 } | |
55 | |
56 void CertListTest::benchmarkValid() | |
57 { | |
58 const char *fname = "list-valid-signed.txt"; | |
59 | |
60 QBENCHMARK_ONCE { | |
61 CertificateList *certList = testWithFile(fname); | |
62 delete certList; | |
63 } | |
64 } | |
65 | |
66 CertificateList* CertListTest::testWithFile(const char *filename) | |
67 { | |
68 QDir dataDir = QDir(SOURCE_DIR"/data/"); | |
69 QString fileName = dataDir.absoluteFilePath(filename); | |
70 return new CertificateList(fileName.toLocal8Bit().data()); | |
71 } | |
72 | |
73 int main( int argc, char **argv ) | |
74 { | |
75 CertListTest tc; | |
76 return QTest::qExec( &tc, argc, argv ); | |
77 } | |
78 | |
79 |