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