[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevelop/languages/cpp/parser/tests
From:       Hamish Rodda <rodda () kde ! org>
Date:       2006-07-11 21:29:04
Message-ID: 1152653344.370742.27267.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 561330 by rodda:

Test definition searching for correctness... passes


 M  +17 -5     test_duchain.cpp  


--- trunk/KDE/kdevelop/languages/cpp/parser/tests/test_duchain.cpp #561329:561330
@@ -53,6 +53,7 @@
   Definition* definition2;
   Definition* definition3;
   Definition* definition4;
+  Definition* noDef;
   KUrl file1, file2;
   DUContext* topContext;
 
@@ -85,6 +86,7 @@
     definition4->setType(type2);
     definition4->setIdentifier("m_errorCode2");
 
+    noDef = 0;
 
     file1 = "file:///opt/kde4/src/kdevelop/languages/cpp/parser/duchain.cpp";
     file2 = "file:///opt/kde4/src/kdevelop/languages/cpp/parser/dubuilder.cpp";
@@ -213,6 +215,7 @@
 
     Definition* def = top->localDefinitions().first();
     QCOMPARE(def->identifier(), QString("i"));
+    QCOMPARE(top->findDefinition("i"), def);
 
     //delete top;
   }
@@ -228,21 +231,30 @@
     QCOMPARE(top->childContexts().count(), 1);
     QCOMPARE(top->localDefinitions().count(), 1);
 
-    Definition* def = top->localDefinitions().first();
-    QCOMPARE(def->identifier(), QString("A::t"));
+    Definition* defAT = top->localDefinitions().first();
+    QCOMPARE(defAT->identifier(), QString("A::t"));
 
+    QCOMPARE(top->findDefinition("A::t"), defAT);
+    QCOMPARE(top->findDefinition("i"), noDef);
+
     DUContext* fn = top->childContexts().first();
     QCOMPARE(fn->childContexts().count(), 1);
     QCOMPARE(fn->localDefinitions().count(), 1);
 
-    def = fn->localDefinitions().first();
-    QCOMPARE(def->identifier(), QString("i"));
-    QCOMPARE(def->uses().count(), 2);
+    Definition* defI = fn->localDefinitions().first();
+    QCOMPARE(defI->identifier(), QString("i"));
+    QCOMPARE(defI->uses().count(), 2);
 
+    QCOMPARE(fn->findDefinition("A::t"), defAT);
+    QCOMPARE(fn->findDefinition("i"), defI);
+
     DUContext* insideFn = fn->childContexts().first();
     QCOMPARE(insideFn->childContexts().count(), 0);
     QCOMPARE(insideFn->localDefinitions().count(), 0);
 
+    QCOMPARE(insideFn->findDefinition("A::t"), defAT);
+    QCOMPARE(insideFn->findDefinition("i"), defI);
+
     //delete top;
   }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic