Commit 34efcf31 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

More testing.

parent 0d314977
......@@ -12,6 +12,17 @@
CPLUSPLUS_USE_NAMESPACE
template <template <typename, typename> class _Map, typename _T1, typename _T2>
_Map<_T2, _T1> invert(const _Map<_T1, _T2> &m)
{
_Map<_T2, _T1> i;
typename _Map<_T1, _T2>::const_iterator it = m.constBegin();
for (; it != m.constEnd(); ++it) {
i.insertMulti(it.value(), it.key());
}
return i;
}
class ClassSymbols: protected ASTVisitor,
public QMap<ClassSpecifierAST *, Class *>
{
......@@ -20,6 +31,9 @@ public:
: ASTVisitor(control)
{ }
QMap<ClassSpecifierAST *, Class *> asMap() const
{ return *this; }
void operator()(AST *ast)
{ accept(ast); }
......@@ -62,7 +76,7 @@ void tst_Lookup::base_class_defined_1()
Snapshot snapshot;
snapshot.insert(doc->fileName(), doc);
Document::Ptr emptyDoc = Document::create("empty");
Document::Ptr emptyDoc = Document::create("<empty>");
Class *baseClass = doc->globalSymbolAt(0)->asClass();
QVERIFY(baseClass);
......@@ -88,6 +102,12 @@ void tst_Lookup::base_class_defined_1()
classSymbols(ast);
QCOMPARE(classSymbols.size(), 2);
const QMap<Class *, ClassSpecifierAST *> classToAST =
invert(classSymbols.asMap());
QVERIFY(classToAST.value(baseClass) != 0);
QVERIFY(classToAST.value(derivedClass) != 0);
}
QTEST_APPLESS_MAIN(tst_Lookup)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment