test: Rename test case name TestQtJson -> tst_QtJson

This allows us to follow test naming convention which should start
with "tst_"

 Before:
  TestQtJson::initTestCase()

 After:
  tst_QtJson::initTestCase()

Change-Id: Id83ccc324776399184c3665565eb8d045bfee2e2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Sergio Ahumada 2012-10-22 12:39:02 +02:00 committed by The Qt Project
parent ead0e0029a
commit cd0c6d69fa

View File

@ -48,11 +48,11 @@
#define INVALID_UNICODE "\357\277\277" // "\uffff" #define INVALID_UNICODE "\357\277\277" // "\uffff"
#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet #define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet
class TestQtJson: public QObject class tst_QtJson: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TestQtJson(QObject *parent = 0); tst_QtJson(QObject *parent = 0);
private Q_SLOTS: private Q_SLOTS:
void initTestCase(); void initTestCase();
@ -132,30 +132,30 @@ private:
QString testDataDir; QString testDataDir;
}; };
TestQtJson::TestQtJson(QObject *parent) : QObject(parent) tst_QtJson::tst_QtJson(QObject *parent) : QObject(parent)
{ {
} }
void TestQtJson::initTestCase() void tst_QtJson::initTestCase()
{ {
testDataDir = QFileInfo(QFINDTESTDATA("test.json")).absolutePath(); testDataDir = QFileInfo(QFINDTESTDATA("test.json")).absolutePath();
if (testDataDir.isEmpty()) if (testDataDir.isEmpty())
testDataDir = QCoreApplication::applicationDirPath(); testDataDir = QCoreApplication::applicationDirPath();
} }
void TestQtJson::cleanupTestCase() void tst_QtJson::cleanupTestCase()
{ {
} }
void TestQtJson::init() void tst_QtJson::init()
{ {
} }
void TestQtJson::cleanup() void tst_QtJson::cleanup()
{ {
} }
void TestQtJson::testValueSimple() void tst_QtJson::testValueSimple()
{ {
QJsonObject object; QJsonObject object;
object.insert("number", 999.); object.insert("number", 999.);
@ -206,7 +206,7 @@ void TestQtJson::testValueSimple()
QCOMPARE(value.toArray(), QJsonArray()); QCOMPARE(value.toArray(), QJsonArray());
} }
void TestQtJson::testNumbers() void tst_QtJson::testNumbers()
{ {
{ {
int numbers[] = { int numbers[] = {
@ -274,7 +274,7 @@ void TestQtJson::testNumbers()
} }
void TestQtJson::testObjectSimple() void tst_QtJson::testObjectSimple()
{ {
QJsonObject object; QJsonObject object;
object.insert("number", 999.); object.insert("number", 999.);
@ -311,7 +311,7 @@ void TestQtJson::testObjectSimple()
QVERIFY2(object.value("string").toString() != before, "value should have been updated"); QVERIFY2(object.value("string").toString() != before, "value should have been updated");
} }
void TestQtJson::testObjectSmallKeys() void tst_QtJson::testObjectSmallKeys()
{ {
QJsonObject data1; QJsonObject data1;
data1.insert(QStringLiteral("1"), 123); data1.insert(QStringLiteral("1"), 123);
@ -327,7 +327,7 @@ void TestQtJson::testObjectSmallKeys()
QCOMPARE(data1.value(QStringLiteral("123")).toDouble(), (double)323); QCOMPARE(data1.value(QStringLiteral("123")).toDouble(), (double)323);
} }
void TestQtJson::testArraySimple() void tst_QtJson::testArraySimple()
{ {
QJsonArray array; QJsonArray array;
array.append(999.); array.append(999.);
@ -380,7 +380,7 @@ void TestQtJson::testArraySimple()
QCOMPARE(array.at(1), QJsonValue(QLatin1String("test"))); QCOMPARE(array.at(1), QJsonValue(QLatin1String("test")));
} }
void TestQtJson::testValueObject() void tst_QtJson::testValueObject()
{ {
QJsonObject object; QJsonObject object;
object.insert("number", 999.); object.insert("number", 999.);
@ -398,7 +398,7 @@ void TestQtJson::testValueObject()
QVERIFY2(value.toObject() != object, "object should have detached"); QVERIFY2(value.toObject() != object, "object should have detached");
} }
void TestQtJson::testValueArray() void tst_QtJson::testValueArray()
{ {
QJsonArray array; QJsonArray array;
array.append(999.); array.append(999.);
@ -416,7 +416,7 @@ void TestQtJson::testValueArray()
QVERIFY2(value.toArray() != array, "array should have detached"); QVERIFY2(value.toArray() != array, "array should have detached");
} }
void TestQtJson::testObjectNested() void tst_QtJson::testObjectNested()
{ {
QJsonObject inner, outer; QJsonObject inner, outer;
inner.insert("number", 999.); inner.insert("number", 999.);
@ -453,7 +453,7 @@ void TestQtJson::testObjectNested()
true); true);
} }
void TestQtJson::testArrayNested() void tst_QtJson::testArrayNested()
{ {
QJsonArray inner, outer; QJsonArray inner, outer;
inner.append(999.); inner.append(999.);
@ -487,7 +487,7 @@ void TestQtJson::testArrayNested()
QCOMPARE(outer.last().toArray().last().toArray().at(0).toString(), QString("nested")); QCOMPARE(outer.last().toArray().last().toArray().at(0).toString(), QString("nested"));
} }
void TestQtJson::testArrayNestedEmpty() void tst_QtJson::testArrayNestedEmpty()
{ {
QJsonObject object; QJsonObject object;
QJsonArray inner; QJsonArray inner;
@ -504,7 +504,7 @@ void TestQtJson::testArrayNestedEmpty()
QCOMPARE(object.value("inner").toArray().size(), 0); QCOMPARE(object.value("inner").toArray().size(), 0);
} }
void TestQtJson::testObjectNestedEmpty() void tst_QtJson::testObjectNestedEmpty()
{ {
QJsonObject object; QJsonObject object;
QJsonObject inner; QJsonObject inner;
@ -529,7 +529,7 @@ void TestQtJson::testObjectNestedEmpty()
QCOMPARE(reconstituted.value("inner2").type(), QJsonValue::Object); QCOMPARE(reconstituted.value("inner2").type(), QJsonValue::Object);
} }
void TestQtJson::testValueRef() void tst_QtJson::testValueRef()
{ {
QJsonArray array; QJsonArray array;
array.append(1.); array.append(1.);
@ -560,7 +560,7 @@ void TestQtJson::testValueRef()
QCOMPARE(object.value(QLatin1String("key")), QJsonValue(42)); QCOMPARE(object.value(QLatin1String("key")), QJsonValue(42));
} }
void TestQtJson::testObjectIteration() void tst_QtJson::testObjectIteration()
{ {
QJsonObject object; QJsonObject object;
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
@ -630,7 +630,7 @@ void TestQtJson::testObjectIteration()
QVERIFY(it == object.end()); QVERIFY(it == object.end());
} }
void TestQtJson::testArrayIteration() void tst_QtJson::testArrayIteration()
{ {
QJsonArray array; QJsonArray array;
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
@ -691,7 +691,7 @@ void TestQtJson::testArrayIteration()
QVERIFY(it == array.end()); QVERIFY(it == array.end());
} }
void TestQtJson::testObjectFind() void tst_QtJson::testObjectFind()
{ {
QJsonObject object; QJsonObject object;
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
@ -712,7 +712,7 @@ void TestQtJson::testObjectFind()
QVERIFY(it == object.end()); QVERIFY(it == object.end());
} }
void TestQtJson::testDocument() void tst_QtJson::testDocument()
{ {
QJsonDocument doc; QJsonDocument doc;
QCOMPARE(doc.isEmpty(), true); QCOMPARE(doc.isEmpty(), true);
@ -786,7 +786,7 @@ void TestQtJson::testDocument()
QCOMPARE(doc5.array().at(0), QJsonValue(23)); QCOMPARE(doc5.array().at(0), QJsonValue(23));
} }
void TestQtJson::nullValues() void tst_QtJson::nullValues()
{ {
QJsonArray array; QJsonArray array;
array.append(QJsonValue()); array.append(QJsonValue());
@ -801,7 +801,7 @@ void TestQtJson::nullValues()
QCOMPARE(object.value("key"), QJsonValue()); QCOMPARE(object.value("key"), QJsonValue());
} }
void TestQtJson::nullArrays() void tst_QtJson::nullArrays()
{ {
QJsonArray nullArray; QJsonArray nullArray;
QJsonArray nonNull; QJsonArray nonNull;
@ -829,7 +829,7 @@ void TestQtJson::nullArrays()
nullArray.removeAt(-1); nullArray.removeAt(-1);
} }
void TestQtJson::nullObject() void tst_QtJson::nullObject()
{ {
QJsonObject nullObject; QJsonObject nullObject;
QJsonObject nonNull; QJsonObject nonNull;
@ -857,7 +857,7 @@ void TestQtJson::nullObject()
QCOMPARE(nullObject.contains("foo"), false); QCOMPARE(nullObject.contains("foo"), false);
} }
void TestQtJson::keySorting() void tst_QtJson::keySorting()
{ {
const char *json = "{ \"B\": true, \"A\": false }"; const char *json = "{ \"B\": true, \"A\": false }";
QJsonDocument doc = QJsonDocument::fromJson(json); QJsonDocument doc = QJsonDocument::fromJson(json);
@ -872,7 +872,7 @@ void TestQtJson::keySorting()
QCOMPARE(it.key(), QLatin1String("B")); QCOMPARE(it.key(), QLatin1String("B"));
} }
void TestQtJson::undefinedValues() void tst_QtJson::undefinedValues()
{ {
QJsonObject object; QJsonObject object;
object.insert("Key", QJsonValue(QJsonValue::Undefined)); object.insert("Key", QJsonValue(QJsonValue::Undefined));
@ -896,7 +896,7 @@ void TestQtJson::undefinedValues()
} }
void TestQtJson::fromVariantMap() void tst_QtJson::fromVariantMap()
{ {
QVariantMap map; QVariantMap map;
map.insert(QLatin1String("key1"), QLatin1String("value1")); map.insert(QLatin1String("key1"), QLatin1String("value1"));
@ -928,7 +928,7 @@ void TestQtJson::fromVariantMap()
QCOMPARE(array.at(3).toString(), QLatin1String("foo")); QCOMPARE(array.at(3).toString(), QLatin1String("foo"));
} }
void TestQtJson::toVariantMap() void tst_QtJson::toVariantMap()
{ {
QJsonObject object; QJsonObject object;
QVariantMap map = object.toVariantMap(); QVariantMap map = object.toVariantMap();
@ -957,7 +957,7 @@ void TestQtJson::toVariantMap()
QCOMPARE(list.at(3), QVariant()); QCOMPARE(list.at(3), QVariant());
} }
void TestQtJson::toVariantList() void tst_QtJson::toVariantList()
{ {
QJsonArray array; QJsonArray array;
QVariantList list = array.toVariantList(); QVariantList list = array.toVariantList();
@ -986,7 +986,7 @@ void TestQtJson::toVariantList()
QCOMPARE(vlist.at(3), QVariant()); QCOMPARE(vlist.at(3), QVariant());
} }
void TestQtJson::toJson() void tst_QtJson::toJson()
{ {
QJsonObject object; QJsonObject object;
object.insert("\\Key\n", QString("Value")); object.insert("\\Key\n", QString("Value"));
@ -1033,7 +1033,7 @@ void TestQtJson::toJson()
QCOMPARE(json, expected); QCOMPARE(json, expected);
} }
void TestQtJson::fromJson() void tst_QtJson::fromJson()
{ {
{ {
QByteArray json = "[\n true\n]\n"; QByteArray json = "[\n true\n]\n";
@ -1122,7 +1122,7 @@ void TestQtJson::fromJson()
} }
} }
void TestQtJson::fromJsonErrors() void tst_QtJson::fromJsonErrors()
{ {
{ {
QJsonParseError error; QJsonParseError error;
@ -1286,7 +1286,7 @@ void TestQtJson::fromJsonErrors()
} }
} }
void TestQtJson::fromBinary() void tst_QtJson::fromBinary()
{ {
QFile file(testDataDir + "/test.json"); QFile file(testDataDir + "/test.json");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
@ -1307,14 +1307,14 @@ void TestQtJson::fromBinary()
QVERIFY(doc == bdoc); QVERIFY(doc == bdoc);
} }
void TestQtJson::toAndFromBinary_data() void tst_QtJson::toAndFromBinary_data()
{ {
QTest::addColumn<QString>("filename"); QTest::addColumn<QString>("filename");
QTest::newRow("test.json") << (testDataDir + "/test.json"); QTest::newRow("test.json") << (testDataDir + "/test.json");
QTest::newRow("test2.json") << (testDataDir + "/test2.json"); QTest::newRow("test2.json") << (testDataDir + "/test2.json");
} }
void TestQtJson::toAndFromBinary() void tst_QtJson::toAndFromBinary()
{ {
QFETCH(QString, filename); QFETCH(QString, filename);
QFile file(filename); QFile file(filename);
@ -1328,7 +1328,7 @@ void TestQtJson::toAndFromBinary()
QVERIFY(doc == outdoc); QVERIFY(doc == outdoc);
} }
void TestQtJson::parseNumbers() void tst_QtJson::parseNumbers()
{ {
{ {
// test number parsing // test number parsing
@ -1406,7 +1406,7 @@ void TestQtJson::parseNumbers()
} }
} }
void TestQtJson::parseStrings() void tst_QtJson::parseStrings()
{ {
const char *strings [] = const char *strings [] =
{ {
@ -1471,7 +1471,7 @@ void TestQtJson::parseStrings()
} }
void TestQtJson::parseDuplicateKeys() void tst_QtJson::parseDuplicateKeys()
{ {
const char *json = "{ \"B\": true, \"A\": null, \"B\": false }"; const char *json = "{ \"B\": true, \"A\": null, \"B\": false }";
@ -1488,7 +1488,7 @@ void TestQtJson::parseDuplicateKeys()
QCOMPARE(it.value(), QJsonValue(false)); QCOMPARE(it.value(), QJsonValue(false));
} }
void TestQtJson::testParser() void tst_QtJson::testParser()
{ {
QFile file(testDataDir + "/test.json"); QFile file(testDataDir + "/test.json");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
@ -1498,7 +1498,7 @@ void TestQtJson::testParser()
QVERIFY(!doc.isEmpty()); QVERIFY(!doc.isEmpty());
} }
void TestQtJson::compactArray() void tst_QtJson::compactArray()
{ {
QJsonArray array; QJsonArray array;
array.append(QLatin1String("First Entry")); array.append(QLatin1String("First Entry"));
@ -1535,7 +1535,7 @@ void TestQtJson::compactArray()
} }
void TestQtJson::compactObject() void tst_QtJson::compactObject()
{ {
QJsonObject object; QJsonObject object;
object.insert(QLatin1String("Key1"), QLatin1String("First Entry")); object.insert(QLatin1String("Key1"), QLatin1String("First Entry"));
@ -1572,7 +1572,7 @@ void TestQtJson::compactObject()
} }
void TestQtJson::validation() void tst_QtJson::validation()
{ {
// this basically tests that we don't crash on corrupt data // this basically tests that we don't crash on corrupt data
QFile file(testDataDir + "/test.json"); QFile file(testDataDir + "/test.json");
@ -1623,7 +1623,7 @@ void TestQtJson::validation()
} }
} }
void TestQtJson::assignToDocument() void tst_QtJson::assignToDocument()
{ {
{ {
const char *json = "{ \"inner\": { \"key\": true } }"; const char *json = "{ \"inner\": { \"key\": true } }";
@ -1652,7 +1652,7 @@ void TestQtJson::assignToDocument()
} }
void TestQtJson::testDuplicateKeys() void tst_QtJson::testDuplicateKeys()
{ {
QJsonObject obj; QJsonObject obj;
obj.insert(QLatin1String("foo"), QLatin1String("bar")); obj.insert(QLatin1String("foo"), QLatin1String("bar"));
@ -1661,7 +1661,7 @@ void TestQtJson::testDuplicateKeys()
QCOMPARE(obj.value(QLatin1String("foo")).toString(), QLatin1String("zap")); QCOMPARE(obj.value(QLatin1String("foo")).toString(), QLatin1String("zap"));
} }
void TestQtJson::testCompaction() void tst_QtJson::testCompaction()
{ {
// modify object enough times to trigger compactionCounter // modify object enough times to trigger compactionCounter
// and make sure the data is still valid // and make sure the data is still valid
@ -1681,7 +1681,7 @@ void TestQtJson::testCompaction()
QVERIFY(doc.object() == obj); QVERIFY(doc.object() == obj);
} }
void TestQtJson::testDebugStream() void tst_QtJson::testDebugStream()
{ {
{ {
// QJsonObject // QJsonObject
@ -1768,7 +1768,7 @@ void TestQtJson::testDebugStream()
} }
} }
void TestQtJson::testCompactionError() void tst_QtJson::testCompactionError()
{ {
QJsonObject schemaObject; QJsonObject schemaObject;
schemaObject.insert("_Type", QLatin1String("_SchemaType")); schemaObject.insert("_Type", QLatin1String("_SchemaType"));
@ -1796,7 +1796,7 @@ void TestQtJson::testCompactionError()
} }
} }
void TestQtJson::parseUnicodeEscapes() void tst_QtJson::parseUnicodeEscapes()
{ {
const QByteArray json = "[ \"A\\u00e4\\u00C4\" ]"; const QByteArray json = "[ \"A\\u00e4\\u00C4\" ]";
@ -1810,7 +1810,7 @@ void TestQtJson::parseUnicodeEscapes()
QCOMPARE(array.first().toString(), result); QCOMPARE(array.first().toString(), result);
} }
void TestQtJson::assignObjects() void tst_QtJson::assignObjects()
{ {
const char *json = const char *json =
"[ { \"Key\": 1 }, { \"Key\": 2 } ]"; "[ { \"Key\": 1 }, { \"Key\": 2 } ]";
@ -1825,7 +1825,7 @@ void TestQtJson::assignObjects()
QCOMPARE(object.value("Key").toDouble(), 2.); QCOMPARE(object.value("Key").toDouble(), 2.);
} }
void TestQtJson::assignArrays() void tst_QtJson::assignArrays()
{ {
const char *json = const char *json =
"[ [ 1 ], [ 2 ] ]"; "[ [ 1 ], [ 2 ] ]";
@ -1840,7 +1840,7 @@ void TestQtJson::assignArrays()
QCOMPARE(inner.at(0).toDouble(), 2.); QCOMPARE(inner.at(0).toDouble(), 2.);
} }
void TestQtJson::testTrailingComma() void tst_QtJson::testTrailingComma()
{ {
const char *jsons[] = { "{ \"Key\": 1, }", "[ { \"Key\": 1 }, ]" }; const char *jsons[] = { "{ \"Key\": 1, }", "[ { \"Key\": 1 }, ]" };
@ -1851,7 +1851,7 @@ void TestQtJson::testTrailingComma()
} }
} }
void TestQtJson::testDetachBug() void tst_QtJson::testDetachBug()
{ {
QJsonObject dynamic; QJsonObject dynamic;
QJsonObject embedded; QJsonObject embedded;
@ -1875,7 +1875,7 @@ void TestQtJson::testDetachBug()
QCOMPARE(local.keys().size(), 1); QCOMPARE(local.keys().size(), 1);
} }
void TestQtJson::valueEquals() void tst_QtJson::valueEquals()
{ {
QVERIFY(QJsonValue() == QJsonValue()); QVERIFY(QJsonValue() == QJsonValue());
QVERIFY(QJsonValue() != QJsonValue(QJsonValue::Undefined)); QVERIFY(QJsonValue() != QJsonValue(QJsonValue::Undefined));
@ -1921,7 +1921,7 @@ void TestQtJson::valueEquals()
QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(QJsonArray())); QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(QJsonArray()));
} }
void TestQtJson::bom() void tst_QtJson::bom()
{ {
QFile file(testDataDir + "/bom.json"); QFile file(testDataDir + "/bom.json");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
@ -1935,7 +1935,7 @@ void TestQtJson::bom()
QVERIFY(error.error == QJsonParseError::NoError); QVERIFY(error.error == QJsonParseError::NoError);
} }
void TestQtJson::nesting() void tst_QtJson::nesting()
{ {
// check that we abort parsing too deeply nested json documents. // check that we abort parsing too deeply nested json documents.
// this is to make sure we don't crash because the parser exhausts the // this is to make sure we don't crash because the parser exhausts the
@ -1994,5 +1994,5 @@ void TestQtJson::nesting()
} }
QTEST_MAIN(TestQtJson) QTEST_MAIN(tst_QtJson)
#include "tst_qtjson.moc" #include "tst_qtjson.moc"