Changeset View
Changeset View
Standalone View
Standalone View
autotests/ksycocadicttest.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 100 | while (it.hasNext()) { | |||
---|---|---|---|---|---|
103 | } | 103 | } | ||
104 | } | 104 | } | ||
105 | qDebug() << serviceTypes; | 105 | qDebug() << serviceTypes; | ||
106 | 106 | | |||
107 | QBENCHMARK { | 107 | QBENCHMARK { | ||
108 | QByteArray buffer; | 108 | QByteArray buffer; | ||
109 | { | 109 | { | ||
110 | KSycocaDict dict; | 110 | KSycocaDict dict; | ||
111 | foreach (const QString &str, serviceTypes) | 111 | for (const QString &str : qAsConst(serviceTypes)) | ||
112 | { | 112 | { | ||
113 | add(dict, str, str); | 113 | add(dict, str, str); | ||
114 | } | 114 | } | ||
115 | dict.remove(QStringLiteral("DictTestPluginType")); // just to test remove | 115 | dict.remove(QStringLiteral("DictTestPluginType")); // just to test remove | ||
116 | add(dict, QStringLiteral("DictTestPluginType"), QStringLiteral("DictTestPluginType")); | 116 | add(dict, QStringLiteral("DictTestPluginType"), QStringLiteral("DictTestPluginType")); | ||
117 | QCOMPARE(int(dict.count()), serviceTypes.count()); | 117 | QCOMPARE(int(dict.count()), serviceTypes.count()); | ||
118 | QDataStream saveStream(&buffer, QIODevice::WriteOnly); | 118 | QDataStream saveStream(&buffer, QIODevice::WriteOnly); | ||
119 | dict.save(saveStream); | 119 | dict.save(saveStream); | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | QDataStream stream(buffer); | 122 | QDataStream stream(buffer); | ||
123 | KSycocaDict loadingDict(&stream, 0); | 123 | KSycocaDict loadingDict(&stream, 0); | ||
124 | int offset = loadingDict.find_string(QStringLiteral("DictTestPluginType")); | 124 | int offset = loadingDict.find_string(QStringLiteral("DictTestPluginType")); | ||
125 | QVERIFY(offset > 0); | 125 | QVERIFY(offset > 0); | ||
126 | QCOMPARE(offset, KServiceType::serviceType(QStringLiteral("DictTestPluginType"))->offset()); | 126 | QCOMPARE(offset, KServiceType::serviceType(QStringLiteral("DictTestPluginType"))->offset()); | ||
127 | foreach (const QString &str, serviceTypes) | 127 | for (const QString &str : qAsConst(serviceTypes)) | ||
128 | { | 128 | { | ||
129 | int offset = loadingDict.find_string(str); | 129 | int offset = loadingDict.find_string(str); | ||
130 | QVERIFY(offset > 0); | 130 | QVERIFY(offset > 0); | ||
131 | QCOMPARE(offset, KServiceType::serviceType(str)->offset()); | 131 | QCOMPARE(offset, KServiceType::serviceType(str)->offset()); | ||
132 | } | 132 | } | ||
133 | offset = loadingDict.find_string(QStringLiteral("doesnotexist")); | 133 | offset = loadingDict.find_string(QStringLiteral("doesnotexist")); | ||
134 | // TODO QCOMPARE(offset, 0); // could be non 0 according to the docs, too; if non 0, we should check that the pointed mimetype doesn't have this name. | 134 | // TODO QCOMPARE(offset, 0); // could be non 0 according to the docs, too; if non 0, we should check that the pointed mimetype doesn't have this name. | ||
135 | } | 135 | } | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | #include "ksycocadicttest.moc" | 138 | #include "ksycocadicttest.moc" |