comparison ui/tests/commontest.cpp @ 243:4b67cc2d4dad

Merged
author Sascha Wilde <wilde@intevation.de>
date Fri, 28 Mar 2014 18:38:34 +0100
parents 6b4ad6ccc48e
children 17e1c8f37d72
comparison
equal deleted inserted replaced
242:809eaca3898c 243:4b67cc2d4dad
2 #include <QByteArray> 2 #include <QByteArray>
3 #include <QTest> 3 #include <QTest>
4 4
5 #include "commontest.h" 5 #include "commontest.h"
6 #include "strhelp.h" 6 #include "strhelp.h"
7
8 void CommonTest::testInvalidInput() {
9 const char * foo = "Zm9vA"; /* Invalid input with a bit valid input */
10 char *data = NULL;
11 size_t data_size = 0;
12 int ret = -1;
13 ret = str_base64_decode(&data, &data_size, (char *)foo, 5);
14
15 QVERIFY(ret == 0);
16 QVERIFY(data == QString::fromLatin1("foo"));
17 free(data);
18 }
7 19
8 void CommonTest::testStrBase64Decode() { 20 void CommonTest::testStrBase64Decode() {
9 char garbage[1000]; 21 char garbage[1000];
10 char *data = NULL; 22 char *data = NULL;
11 size_t data_size = 0; 23 size_t data_size = 0;
22 34
23 QVERIFY(ret == 0); 35 QVERIFY(ret == 0);
24 QVERIFY(data_size == 1000); 36 QVERIFY(data_size == 1000);
25 QVERIFY(data); 37 QVERIFY(data);
26 38
27 ret = str_base64_decode(&data, &data_size, (char *)ba.constData(), ba.size());
28 QVERIFY(ret != 0);
29
30 const char * foo = "bla";
31 ret = str_base64_decode(&data, &data_size, (char *)foo, 3);
32 QVERIFY(ret != 0);
33
34 for (size_t i = 0; i < data_size; i++) { 39 for (size_t i = 0; i < data_size; i++) {
35 QVERIFY(garbage[i] == data[i]); 40 QVERIFY(garbage[i] == data[i]);
36 } 41 }
37 free (data); 42 free (data);
38 } 43 }

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