| 46 | } |
| 47 | |
| 48 | void 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 | |
| 70 | void TestAstyle::testTabMatching() |
| 71 | { |