diff ui/tests/certlistparsertest.cpp @ 240:c05e126b0b9e

Fix downloadertest and factor out generating file input.
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 28 Mar 2014 15:21:02 +0000
parents 825b42da1855
children 6a7eb102716d
line wrap: on
line diff
--- a/ui/tests/certlistparsertest.cpp	Fri Mar 28 14:20:08 2014 +0000
+++ b/ui/tests/certlistparsertest.cpp	Fri Mar 28 15:21:02 2014 +0000
@@ -1,6 +1,7 @@
 #include "certlistparsertest.h"
 #include "certificatelist.h"
 #include "certificate.h"
+#include "common.h"
 
 #include <QDebug>
 
@@ -114,37 +115,6 @@
     delete certList;
 }
 
-QString CertListTest::getRandomDataFile(size_t size)
-{
-    QTemporaryFile tmpfile;
-    tmpfile.setAutoRemove(false);
-    tmpfile.open();
-    size_t bufsize = 1024 * 1024;
-    if (bufsize > size) {
-        bufsize = size;
-    }
-    char buf[bufsize];
-
-    for (size_t i = 0; i < bufsize; i++) {
-        buf[i] = (char) qrand() % 255;
-    }
-
-    size_t bytesWritten=0;
-    int retval = 0;
-    do {
-        size_t toWrite = size - bytesWritten;
-        if (toWrite < bufsize) {
-            retval = tmpfile.write(buf, toWrite);
-        } else {
-            retval = tmpfile.write(buf, bufsize);
-        }
-        bytesWritten += retval;
-    } while (retval != -1 && bytesWritten < size);
-
-    tmpfile.close();
-    return tmpfile.fileName();
-}
-
 void CertListTest::testTooLarge()
 {
     QString fname = getRandomDataFile(MAX_LINE_LENGTH * MAX_LINES + 1);

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