Changeset View
Changeset View
Standalone View
Standalone View
autotests/syntaxrepository_test.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 86 | { | |||
---|---|---|---|---|---|
93 | } else { | 93 | } else { | ||
94 | QVERIFY(def.isValid()); | 94 | QVERIFY(def.isValid()); | ||
95 | QCOMPARE(def.name(), defName); | 95 | QCOMPARE(def.name(), defName); | ||
96 | } | 96 | } | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | void testLoadAll() | 99 | void testLoadAll() | ||
100 | { | 100 | { | ||
101 | foreach (const auto &def, m_repo.definitions()) { | 101 | for (const auto &def : m_repo.definitions()) { | ||
102 | QVERIFY(!def.name().isEmpty()); | 102 | QVERIFY(!def.name().isEmpty()); | ||
103 | QVERIFY(!def.translatedName().isEmpty()); | 103 | QVERIFY(!def.translatedName().isEmpty()); | ||
104 | QVERIFY(!def.isValid() || !def.section().isEmpty()); | 104 | QVERIFY(!def.isValid() || !def.section().isEmpty()); | ||
105 | QVERIFY(!def.isValid() || !def.translatedSection().isEmpty()); | 105 | QVERIFY(!def.isValid() || !def.translatedSection().isEmpty()); | ||
106 | // indirectly trigger loading, as we can't reach that from public API | 106 | // indirectly trigger loading, as we can't reach that from public API | ||
107 | // if the loading fails the highlighter will produce empty states | 107 | // if the loading fails the highlighter will produce empty states | ||
108 | NullHighlighter hl; | 108 | NullHighlighter hl; | ||
109 | State initialState; | 109 | State initialState; | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 172 | { | |||
178 | // verify that the formats are sorted, such that the order matches the order of the itemDatas in the xml files. | 178 | // verify that the formats are sorted, such that the order matches the order of the itemDatas in the xml files. | ||
179 | auto sortComparator = [](const KSyntaxHighlighting::Format & lhs, const KSyntaxHighlighting::Format & rhs) { | 179 | auto sortComparator = [](const KSyntaxHighlighting::Format & lhs, const KSyntaxHighlighting::Format & rhs) { | ||
180 | return lhs.id() < rhs.id(); | 180 | return lhs.id() < rhs.id(); | ||
181 | }; | 181 | }; | ||
182 | QVERIFY(std::is_sorted(formats.begin(), formats.end(), sortComparator)); | 182 | QVERIFY(std::is_sorted(formats.begin(), formats.end(), sortComparator)); | ||
183 | 183 | | |||
184 | // check all names are listed | 184 | // check all names are listed | ||
185 | QStringList formatNames; | 185 | QStringList formatNames; | ||
186 | foreach (const auto & format, formats) { | 186 | for (const auto & format : qAsConst(formats)) { | ||
187 | formatNames.append(format.name()); | 187 | formatNames.append(format.name()); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | const QStringList expectedItemDatas = { | 190 | const QStringList expectedItemDatas = { | ||
191 | QStringLiteral("Normal Text"), | 191 | QStringLiteral("Normal Text"), | ||
192 | QStringLiteral("Name"), | 192 | QStringLiteral("Name"), | ||
193 | QStringLiteral("E-Mail"), | 193 | QStringLiteral("E-Mail"), | ||
194 | QStringLiteral("Date"), | 194 | QStringLiteral("Date"), | ||
Show All 26 Lines | 219 | for (auto d : defs) { | |||
221 | definitionNames.push_back(d.name()); | 221 | definitionNames.push_back(d.name()); | ||
222 | } | 222 | } | ||
223 | QCOMPARE(definitionNames, expectedDefinitionNames); | 223 | QCOMPARE(definitionNames, expectedDefinitionNames); | ||
224 | } | 224 | } | ||
225 | 225 | | |||
226 | void testIncludedFormats() | 226 | void testIncludedFormats() | ||
227 | { | 227 | { | ||
228 | QStringList definitionNames; | 228 | QStringList definitionNames; | ||
229 | foreach (const auto &def, m_repo.definitions()) { | 229 | for (const auto &def : m_repo.definitions()) { | ||
230 | definitionNames.push_back(def.name()); | 230 | definitionNames.push_back(def.name()); | ||
231 | } | 231 | } | ||
232 | 232 | | |||
233 | foreach (const QString & name, definitionNames) { | 233 | for (const QString & name : qAsConst(definitionNames)) { | ||
234 | Repository repo; | 234 | Repository repo; | ||
235 | initRepositorySearchPaths(repo); | 235 | initRepositorySearchPaths(repo); | ||
236 | auto def = repo.definitionForName(name); | 236 | auto def = repo.definitionForName(name); | ||
237 | QCOMPARE(m_repo.definitionForName(name).isValid(), def.isValid()); | 237 | QCOMPARE(m_repo.definitionForName(name).isValid(), def.isValid()); | ||
238 | auto includedDefs = def.includedDefinitions(); | 238 | auto includedDefs = def.includedDefinitions(); | ||
239 | includedDefs.push_front(def); | 239 | includedDefs.push_front(def); | ||
240 | 240 | | |||
241 | // collect all formats, shall be numbered from 1.. | 241 | // collect all formats, shall be numbered from 1.. | ||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |