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

Method testIdentifiers

kdevplatform/language/duchain/tests/test_duchain.cpp:868–937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868void TestDUChain::testIdentifiers()
869{
870 QualifiedIdentifier aj(QStringLiteral("::Area::jump"));
871 QCOMPARE(aj.count(), 2);
872 QCOMPARE(aj.explicitlyGlobal(), true);
873 QCOMPARE(aj.at(0), Identifier(QStringLiteral("Area")));
874 QCOMPARE(aj.at(1), Identifier(QStringLiteral("jump")));
875
876 QualifiedIdentifier aj2 = QualifiedIdentifier(QStringLiteral("Area::jump"));
877 QCOMPARE(aj2.count(), 2);
878 QCOMPARE(aj2.explicitlyGlobal(), false);
879 QCOMPARE(aj2.at(0), Identifier(QStringLiteral("Area")));
880 QCOMPARE(aj2.at(1), Identifier(QStringLiteral("jump")));
881 QVERIFY(aj != aj2);
882
883 QVERIFY(QualifiedIdentifier(QString()) == QualifiedIdentifier());
884 QVERIFY(QualifiedIdentifier(QString()).index() == QualifiedIdentifier().index());
885
886 QualifiedIdentifier ajt(QStringLiteral("Area::jump::test"));
887 QualifiedIdentifier jt(QStringLiteral("jump::test"));
888 QualifiedIdentifier ajt2(QStringLiteral("Area::jump::tes"));
889
890 QualifiedIdentifier t(QStringLiteral(" Area<A,B>::jump <F> ::tes<C>"));
891 QCOMPARE(t.count(), 3);
892 QCOMPARE(t.at(0).templateIdentifiersCount(), 2u);
893 QCOMPARE(t.at(1).templateIdentifiersCount(), 1u);
894 QCOMPARE(t.at(2).templateIdentifiersCount(), 1u);
895 QCOMPARE(t.at(0).identifier().str(), QStringLiteral("Area"));
896 QCOMPARE(t.at(1).identifier().str(), QStringLiteral("jump"));
897 QCOMPARE(t.at(2).identifier().str(), QStringLiteral("tes"));
898
899 QualifiedIdentifier op1(QStringLiteral("operator<"));
900 QualifiedIdentifier op2(QStringLiteral("operator<="));
901 QualifiedIdentifier op3(QStringLiteral("operator>"));
902 QualifiedIdentifier op4(QStringLiteral("operator>="));
903 QualifiedIdentifier op5(QStringLiteral("operator()"));
904 QualifiedIdentifier op6(QStringLiteral("operator( )"));
905 QCOMPARE(op1.count(), 1);
906 QCOMPARE(op2.count(), 1);
907 QCOMPARE(op3.count(), 1);
908 QCOMPARE(op4.count(), 1);
909 QCOMPARE(op5.count(), 1);
910 QCOMPARE(op6.count(), 1);
911 QCOMPARE(op4.toString(), QStringLiteral("operator>="));
912 QCOMPARE(op3.toString(), QStringLiteral("operator>"));
913 QCOMPARE(op1.toString(), QStringLiteral("operator<"));
914 QCOMPARE(op2.toString(), QStringLiteral("operator<="));
915 QCOMPARE(op5.toString(), QStringLiteral("operator()"));
916 QCOMPARE(op6.toString(), QStringLiteral("operator( )"));
917 QCOMPARE(QualifiedIdentifier(QStringLiteral("Area<A,B>::jump <F> ::tes<C>")).index(), t.index());
918 QCOMPARE(op4.index(), QualifiedIdentifier(QStringLiteral("operator>=")).index());
919
920 QualifiedIdentifier pushTest(QStringLiteral("foo"));
921 QCOMPARE(pushTest.count(), 1);
922 QCOMPARE(pushTest.toString(), QStringLiteral("foo"));
923 pushTest.push(Identifier(QStringLiteral("bar")));
924 QCOMPARE(pushTest.count(), 2);
925 QCOMPARE(pushTest.toString(), QStringLiteral("foo::bar"));

Callers

nothing calls this directly

Calls 13

explicitlyGlobalMethod · 0.80
strMethod · 0.80
IdentifierClass · 0.50
QualifiedIdentifierClass · 0.50
QStringClass · 0.50
countMethod · 0.45
atMethod · 0.45
indexMethod · 0.45
identifierMethod · 0.45
toStringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected