summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-02-22 09:26:27 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-22 13:00:04 +0100
commit82fb03546bdc5d71b9cb389b68b3c0d4d5a0b241 (patch)
treec3dc1c9cd0257eadd50eaf55f1df44e0ee166ca6 /tests
parent349e04eb7c173ad6e01b866d4c0d517f89e2a201 (diff)
Fix QJson autotest on Windows.
- Fix warning: "Character represented by universal-character-name '\uFFFF' cannot be represented in the current code page (1252). - Fix character conversion - Change source file to plain ASCII, add defines for special characters. Change-Id: I8557e6ba7488f746247f0d78181f14bfb7d5aaae Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 2ac0574ec5..4edbd14305 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -45,6 +45,9 @@
#include "qjsonvalue.h"
#include "qjsondocument.h"
+#define INVALID_UNICODE "\357\277\277" // "\uffff"
+#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet
+
class TestQtJson: public QObject
{
Q_OBJECT
@@ -1205,7 +1208,7 @@ void TestQtJson::fromJsonErrors()
}
{
QJsonParseError error;
- QByteArray json = "[\n \"foo\uffffbar\"]";
+ QByteArray json = "[\n \"foo"INVALID_UNICODE"bar\"]";
QJsonDocument doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isEmpty());
QCOMPARE(error.error, QJsonParseError::StringUTF8Scan);
@@ -1221,7 +1224,7 @@ void TestQtJson::fromJsonErrors()
}
{
QJsonParseError error;
- QByteArray json = "[\n \"cЂa\\u12\"]";
+ QByteArray json = "[\n \"c"UNICODE_DJE"a\\u12\"]";
QJsonDocument doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isEmpty());
QCOMPARE(error.error, QJsonParseError::StringEscapeSequence);
@@ -1229,7 +1232,7 @@ void TestQtJson::fromJsonErrors()
}
{
QJsonParseError error;
- QByteArray json = "[\n \"cЂa\uffffbar\"]";
+ QByteArray json = "[\n \"c"UNICODE_DJE"a"INVALID_UNICODE"bar\"]";
QJsonDocument doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isEmpty());
QCOMPARE(error.error, QJsonParseError::StringUTF8Scan);
@@ -1237,7 +1240,7 @@ void TestQtJson::fromJsonErrors()
}
{
QJsonParseError error;
- QByteArray json = "[\n \"cЂa ]";
+ QByteArray json = "[\n \"c"UNICODE_DJE"a ]";
QJsonDocument doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isEmpty());
QCOMPARE(error.error, QJsonParseError::EndOfString);
@@ -1378,7 +1381,7 @@ void TestQtJson::parseStrings()
"abc\\rabc",
"abc\\tabc",
"abc\\u0019abc",
- "abcЂabc",
+ "abc"UNICODE_DJE"abc",
};
int size = sizeof(strings)/sizeof(const char *);
@@ -1404,7 +1407,7 @@ void TestQtJson::parseStrings()
};
Pairs pairs [] = {
{ "abc\\/abc", "abc/abc" },
- { "abc\\u0402abc", "abcЂabc" },
+ { "abc\\u0402abc", "abc"UNICODE_DJE"abc" },
{ "abc\\u0065abc", "abceabc" }
};
size = sizeof(pairs)/sizeof(Pairs);
@@ -1547,7 +1550,7 @@ void TestQtJson::validation()
// only test the first 1000 bytes. Testing the full file takes too long
for (int i = 0; i < 1000; ++i) {
QByteArray corrupted = binary;
- corrupted[i] = 0xff;
+ corrupted[i] = char(0xff);
QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted);
if (doc.isNull())
continue;
@@ -1567,7 +1570,7 @@ void TestQtJson::validation()
for (int i = 0; i < binary.size(); ++i) {
QByteArray corrupted = binary;
- corrupted[i] = 0xff;
+ corrupted[i] = char(0xff);
QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted);
if (doc.isNull())
continue;