MCPcopy Create free account
hub / github.com/KDE/kdevelop / testFuzzyMatching

Method testFuzzyMatching

plugins/astyle/tests/test_astyle.cpp:48–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void TestAstyle::testFuzzyMatching()
49{
50 // Some formatting styles inserts "{" and "}" parens behind "ifs", or change comment styles
51 // The actual text changes, thus it is difficult to match original and formatted text
52
53 QString leftContext = QStringLiteral("void b() {/*some comment*/\nif( ");
54 QString center = QStringLiteral("a[ 0]");
55 QString rightContext = QStringLiteral(" ) q;\n }\n");
56 QString text = leftContext + center + rightContext;
57 QString formatted = QStringLiteral("void b() {// some comment\n if( a[0] ) {\n q;\n }\n }\n");
58 QString extracted = KDevelop::extractFormattedTextFromContext( formatted, text, QString(), QString() );
59 QCOMPARE( extracted, formatted );
60
61 extracted = KDevelop::extractFormattedTextFromContext( formatted, center, leftContext, rightContext );
62 qDebug() << "extracted" << extracted << "formatted" << formatted;
63 QCOMPARE( extracted, QString("a[0]") );
64
65 rightContext = QStringLiteral("\nvoid g() {}");
66 extracted = KDevelop::extractFormattedTextFromContext(formatted + rightContext, text, QString(), rightContext);
67 QCOMPARE(extracted, formatted);
68}
69
70void TestAstyle::testTabMatching()
71{

Callers

nothing calls this directly

Calls 1

QStringClass · 0.50

Tested by

no test coverage detected