summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbytearray
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qbytearray')
-rw-r--r--tests/auto/qbytearray/.gitattributes1
-rw-r--r--tests/auto/qbytearray/qbytearray.pro7
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp80
3 files changed, 75 insertions, 13 deletions
diff --git a/tests/auto/qbytearray/.gitattributes b/tests/auto/qbytearray/.gitattributes
new file mode 100644
index 0000000..e04709a
--- /dev/null
+++ b/tests/auto/qbytearray/.gitattributes
@@ -0,0 +1 @@
+rfc3252.txt -crlf
diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro
index f41c7ae..d14534b 100644
--- a/tests/auto/qbytearray/qbytearray.pro
+++ b/tests/auto/qbytearray/qbytearray.pro
@@ -4,11 +4,16 @@ SOURCES += tst_qbytearray.cpp
QT = core
-wince*: {
+wince*|symbian: {
addFile.sources = rfc3252.txt
addFile.path = .
DEPLOYMENT += addFile
+}
+
+wince: {
DEFINES += SRCDIR=\\\"\\\"
+} symbian: {
+ TARGET.EPOCHEAPSIZE="0x100 0x800000"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 4f0294f..435724a 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -53,6 +53,10 @@
//TESTED_CLASS=
//TESTED_FILES=
+#if defined(Q_OS_SYMBIAN)
+#define SRCDIR ""
+#endif
+
class tst_QByteArray : public QObject
{
Q_OBJECT
@@ -86,6 +90,8 @@ private slots:
void split();
void base64_data();
void base64();
+ void fromBase64_data();
+ void fromBase64();
void qvsnprintf();
void qstrlen();
void qstrnlen();
@@ -235,14 +241,12 @@ void tst_QByteArray::qUncompress()
QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll);
#elif defined Q_OS_SOLARIS
QSKIP("Corrupt data causes this tests to lock up on Solaris", SkipAll);
+#elif defined Q_OS_QNX
+ QSKIP("Corrupt data causes this test to lock up on QNX", SkipAll);
#endif
QTEST(::qUncompress(in), "out");
-#if defined Q_WS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4)
- QSKIP("Corrupt data causes this test to lock up on Mac OS X Panther", SkipSingle);
-#endif
-
QTEST(::qUncompress(in + "blah"), "out");
}
#endif
@@ -458,6 +462,10 @@ void tst_QByteArray::base64_data()
for (int i = 0; i < 256; ++i)
ba[i] = i;
QTest::newRow("f") << ba << QByteArray("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==");
+
+ QTest::newRow("g") << QByteArray("foo\0bar", 7) << QByteArray("Zm9vAGJhcg==");
+ QTest::newRow("h") << QByteArray("f\xd1oo\x9cbar") << QByteArray("ZtFvb7py");
+ QTest::newRow("i") << QByteArray("\"\0\0\0\0\0\0\"", 8) << QByteArray("IgAAAAAAACI=");
}
@@ -473,6 +481,54 @@ void tst_QByteArray::base64()
QCOMPARE(arr64, base64);
}
+//different from the previous test as the input are invalid
+void tst_QByteArray::fromBase64_data()
+{
+ QTest::addColumn<QByteArray>("rawdata");
+ QTest::addColumn<QByteArray>("base64");
+
+ QTest::newRow("1") << QByteArray("") << QByteArray(" ");
+ QTest::newRow("2") << QByteArray("1") << QByteArray("MQ");
+ QTest::newRow("3") << QByteArray("12") << QByteArray("MTI ");
+ QTest::newRow("4") << QByteArray("123") << QByteArray("M=TIz");
+ QTest::newRow("5") << QByteArray("1234") << QByteArray("MTI zN A ");
+ QTest::newRow("6") << QByteArray("\n") << QByteArray("Cg");
+ QTest::newRow("7") << QByteArray("a\n") << QByteArray("======YQo=");
+ QTest::newRow("8") << QByteArray("ab\n") << QByteArray("Y\nWIK");
+ QTest::newRow("9") << QByteArray("abc\n") << QByteArray("YWJjCg==");
+ QTest::newRow("a") << QByteArray("abcd\n") << QByteArray("YWJ\1j\x9cZAo=");
+ QTest::newRow("b") << QByteArray("abcde\n") << QByteArray("YW JjZ\n G\tUK");
+ QTest::newRow("c") << QByteArray("abcdef\n") << QByteArray("YWJjZGVmCg=");
+ QTest::newRow("d") << QByteArray("abcdefg\n") << QByteArray("YWJ\rjZGVmZwo");
+ QTest::newRow("e") << QByteArray("abcdefgh\n") << QByteArray("YWJjZGVmZ2gK");
+
+ QByteArray ba;
+ ba.resize(256);
+ for (int i = 0; i < 256; ++i)
+ ba[i] = i;
+ QTest::newRow("f") << ba << QByteArray("AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Nj\n"
+ "c4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1u\n"
+ "b3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpa\n"
+ "anqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd\n"
+ "3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w== ");
+
+
+ QTest::newRow("g") << QByteArray("foo\0bar", 7) << QByteArray("Zm9vAGJhcg");
+ QTest::newRow("h") << QByteArray("f\xd1oo\x9cbar") << QByteArray("ZtFv\0b7py", 9);
+ QTest::newRow("i") << QByteArray("\"\0\0\0\0\0\0\"", 8) << QByteArray("IgAAAAAAACI");
+
+}
+
+
+void tst_QByteArray::fromBase64()
+{
+ QFETCH(QByteArray, rawdata);
+ QFETCH(QByteArray, base64);
+
+ QByteArray arr = QByteArray::fromBase64(base64);
+ QCOMPARE(arr, rawdata);
+}
+
void tst_QByteArray::qvsnprintf()
{
char buf[20];
@@ -959,7 +1015,7 @@ void tst_QByteArray::toInt()
QCOMPARE( number, expectednumber );
}
-Q_DECLARE_METATYPE(qulonglong);
+Q_DECLARE_METATYPE(qulonglong)
void tst_QByteArray::toULong_data()
{
QTest::addColumn<QByteArray>("str");
@@ -969,8 +1025,8 @@ void tst_QByteArray::toULong_data()
ulong LongMaxPlusOne = (ulong)LONG_MAX + 1;
QTest::newRow("LONG_MAX+1") << QString::number(LongMaxPlusOne).toLatin1() << 10 << LongMaxPlusOne << true;
- QTest::newRow("default") << QByteArray() << 10 << 0UL << FALSE;
- QTest::newRow("empty") << QByteArray("") << 10 << 0UL << FALSE;
+ QTest::newRow("default") << QByteArray() << 10 << 0UL << false;
+ QTest::newRow("empty") << QByteArray("") << 10 << 0UL << false;
QTest::newRow("ulong1") << QByteArray("3234567890") << 10 << 3234567890UL << true;
QTest::newRow("ulong2") << QByteArray("fFFfFfFf") << 16 << 0xFFFFFFFFUL << true;
}
@@ -995,8 +1051,8 @@ void tst_QByteArray::toULongLong_data()
QTest::addColumn<qulonglong>("result");
QTest::addColumn<bool>("ok");
- QTest::newRow("default") << QByteArray() << 10 << (qulonglong)0 << FALSE;
- QTest::newRow("out of base bound") << QByteArray("c") << 10 << (qulonglong)0 << FALSE;
+ QTest::newRow("default") << QByteArray() << 10 << (qulonglong)0 << false;
+ QTest::newRow("out of base bound") << QByteArray("c") << 10 << (qulonglong)0 << false;
}
@@ -1138,12 +1194,12 @@ void tst_QByteArray::toFromHex()
void tst_QByteArray::toFromPercentEncoding()
{
QByteArray arr("Qt is great!");
-
+/*
QByteArray data = arr.toPercentEncoding();
QCOMPARE(QString(data), QString("Qt%20is%20great%21"));
QCOMPARE(QByteArray::fromPercentEncoding(data), arr);
-
- data = arr.toPercentEncoding("! ", "Qt");
+*/
+ QByteArray data = arr.toPercentEncoding("! ", "Qt");
QCOMPARE(QString(data), QString("%51%74 is grea%74!"));
QCOMPARE(QByteArray::fromPercentEncoding(data), arr);