diff 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
line wrap: on
line diff
--- a/ui/tests/commontest.cpp	Fri Mar 28 18:37:59 2014 +0100
+++ b/ui/tests/commontest.cpp	Fri Mar 28 18:38:34 2014 +0100
@@ -5,6 +5,18 @@
 #include "commontest.h"
 #include "strhelp.h"
 
+void CommonTest::testInvalidInput() {
+    const char * foo = "Zm9vA"; /* Invalid input with a bit valid input */
+    char *data = NULL;
+    size_t data_size = 0;
+    int ret = -1;
+    ret = str_base64_decode(&data, &data_size, (char *)foo, 5);
+
+    QVERIFY(ret == 0);
+    QVERIFY(data == QString::fromLatin1("foo"));
+    free(data);
+}
+
 void CommonTest::testStrBase64Decode() {
     char garbage[1000];
     char *data = NULL;
@@ -24,13 +36,6 @@
     QVERIFY(data_size == 1000);
     QVERIFY(data);
 
-    ret = str_base64_decode(&data, &data_size, (char *)ba.constData(), ba.size());
-    QVERIFY(ret != 0);
-
-    const char * foo = "bla";
-    ret = str_base64_decode(&data, &data_size, (char *)foo, 3);
-    QVERIFY(ret != 0);
-
     for (size_t i = 0; i < data_size; i++) {
         QVERIFY(garbage[i] == data[i]);
     }

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