Changeset View
Changeset View
Standalone View
Standalone View
autotests/syntaxrepository_test.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | 54 | private Q_SLOTS: | |||
---|---|---|---|---|---|
157 | 157 | | |||
158 | void testFormatData() | 158 | void testFormatData() | ||
159 | { | 159 | { | ||
160 | auto def = m_repo.definitionForName(QLatin1String("ChangeLog")); | 160 | auto def = m_repo.definitionForName(QLatin1String("ChangeLog")); | ||
161 | QVERIFY(def.isValid()); | 161 | QVERIFY(def.isValid()); | ||
162 | auto formats = def.formats(); | 162 | auto formats = def.formats(); | ||
163 | QVERIFY(!formats.isEmpty()); | 163 | QVERIFY(!formats.isEmpty()); | ||
164 | 164 | | |||
165 | // verify that the formats are sorted, such that the order matches the order of the itemDatas in the xml files. | ||||
166 | auto sortComparator = [](const KSyntaxHighlighting::Format & lhs, const KSyntaxHighlighting::Format & rhs) { | ||||
167 | return lhs.id() < rhs.id(); | ||||
168 | }; | ||||
169 | QVERIFY(std::is_sorted(formats.begin(), formats.end(), sortComparator)); | ||||
170 | | ||||
171 | // check all names are listed | ||||
165 | QStringList formatNames; | 172 | QStringList formatNames; | ||
166 | foreach (const auto & format, formats) { | 173 | foreach (const auto & format, formats) { | ||
167 | formatNames.append(format.name()); | 174 | formatNames.append(format.name()); | ||
168 | } | 175 | } | ||
169 | QVERIFY(formatNames.contains(QStringLiteral("Normal Text"))); | 176 | | ||
170 | QVERIFY(formatNames.contains(QStringLiteral("Name"))); | 177 | const QStringList expectedItemDatas = { | ||
171 | QVERIFY(formatNames.contains(QStringLiteral("E-Mail"))); | 178 | QStringLiteral("Normal Text"), | ||
172 | QVERIFY(formatNames.contains(QStringLiteral("Date"))); | 179 | QStringLiteral("Name"), | ||
173 | QVERIFY(formatNames.contains(QStringLiteral("Entry"))); | 180 | QStringLiteral("E-Mail"), | ||
174 | QVERIFY(!formatNames.contains(QStringLiteral("Does not Exist"))); | 181 | QStringLiteral("Date"), | ||
182 | QStringLiteral("Entry") | ||||
183 | }; | ||||
184 | QCOMPARE(formatNames, expectedItemDatas); | ||||
175 | } | 185 | } | ||
176 | 186 | | |||
177 | void testIncludedDefinitions() | 187 | void testIncludedDefinitions() | ||
178 | { | 188 | { | ||
179 | auto def = m_repo.definitionForName(QLatin1String("C++")); | 189 | auto def = m_repo.definitionForName(QLatin1String("C++")); | ||
180 | QVERIFY(def.isValid()); | 190 | QVERIFY(def.isValid()); | ||
181 | auto defs = def.includedDefinitions(); | 191 | auto defs = def.includedDefinitions(); | ||
182 | 192 | | |||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |