comparison ui/tests/commontest.cpp @ 182:6c3a089d3265

Add test for str_base64_decode as i suspect it to have a bug
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 25 Mar 2014 17:17:41 +0000
parents
children 1f44aae4528e
comparison
equal deleted inserted replaced
181:bea93c8651b7 182:6c3a089d3265
1 #include <QString>
2 #include <QByteArray>
3 #include <QTest>
4
5 #include "commontest.h"
6 #include "strhelp.h"
7
8 void CommonTest::testStrBase64Decode() {
9 char garbage[1000];
10 char *data = NULL;
11 size_t data_size = 0;
12 int ret;
13 for (int i = 0; i < 1000; i++) {
14 garbage[i] = (char) qrand() % 255;
15 }
16
17 QByteArray ba(garbage, 1000);
18
19 QByteArray baB64 = ba.toBase64();
20
21 ret = str_base64_decode(&data, &data_size, (char *)baB64.constData(), baB64.size());
22
23 QVERIFY(ret == 0);
24 QVERIFY(data_size == 1000);
25
26 for (size_t i = 0; i < data_size; i++) {
27 QVERIFY(garbage[i] == data[i]);
28 }
29 free (data);
30 }
31
32 QTEST_GUILESS_MAIN (CommonTest);

http://wald.intevation.org/projects/trustbridge/