forked from qt-creator/qt-creator
Tests: Add project with suggestions for testing the C++ tools.
This commit is contained in:
24
tests/manual/cplusplus-tools/cplusplus-tools.pro
Normal file
24
tests/manual/cplusplus-tools/cplusplus-tools.pro
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2010-10-01T13:24:32
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = cplusplus-tools
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
dummy.cpp \
|
||||||
|
detail/source.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
dummy.h \
|
||||||
|
detail/header.h
|
||||||
30
tests/manual/cplusplus-tools/detail/header.h
Normal file
30
tests/manual/cplusplus-tools/detail/header.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef HEADER_H
|
||||||
|
#define HEADER_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QString;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
struct A {};
|
||||||
|
struct B : virtual A {};
|
||||||
|
struct C : virtual A {};
|
||||||
|
struct D : B, C {};
|
||||||
|
|
||||||
|
inline int freefunc1()
|
||||||
|
{ return 1; }
|
||||||
|
|
||||||
|
int freefunc2(int);
|
||||||
|
int freefunc2(double);
|
||||||
|
int freefunc2(const QString &);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void freefunc3(T)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void freefunc3(T, int)
|
||||||
|
{}
|
||||||
|
|
||||||
|
#endif //HEADER_H
|
||||||
19
tests/manual/cplusplus-tools/detail/source.cpp
Normal file
19
tests/manual/cplusplus-tools/detail/source.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "header.h"
|
||||||
|
#include "dummy.h"
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
int xi = 10;
|
||||||
|
|
||||||
|
int freefunc2(int a) { return a; }
|
||||||
|
|
||||||
|
int freefunc2(double)
|
||||||
|
{ return 1; }
|
||||||
|
|
||||||
|
int freefunc2(const QString &)
|
||||||
|
{ return 1; }
|
||||||
|
|
||||||
|
void here() {
|
||||||
|
test::Dummy d;
|
||||||
|
d;
|
||||||
|
}
|
||||||
32
tests/manual/cplusplus-tools/dummy.cpp
Normal file
32
tests/manual/cplusplus-tools/dummy.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include "dummy.h"
|
||||||
|
#include "detail/header.h"
|
||||||
|
|
||||||
|
using namespace test;
|
||||||
|
|
||||||
|
extern int xi;
|
||||||
|
|
||||||
|
Dummy::Dummy()
|
||||||
|
{}
|
||||||
|
|
||||||
|
Dummy::Dummy(int)
|
||||||
|
{
|
||||||
|
xi = 0;
|
||||||
|
freefunc2(1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dummy::bla(int)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Dummy::bla(const QString &)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Dummy::bla(const QString &) const
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Dummy::bla(int, const QString &) const
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Dummy::sfunc()
|
||||||
|
{}
|
||||||
|
|
||||||
|
const double Dummy::PI = 3.14;
|
||||||
50
tests/manual/cplusplus-tools/dummy.h
Normal file
50
tests/manual/cplusplus-tools/dummy.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef DUMMY_H
|
||||||
|
#define DUMMY_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace test {
|
||||||
|
|
||||||
|
class Dummy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Dummy();
|
||||||
|
Dummy(int a);
|
||||||
|
|
||||||
|
typedef int INT;
|
||||||
|
|
||||||
|
enum Values {
|
||||||
|
v1,
|
||||||
|
v2,
|
||||||
|
v3
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int ONE = 1;
|
||||||
|
static const double PI;
|
||||||
|
|
||||||
|
static void sfunc();
|
||||||
|
|
||||||
|
struct Internal
|
||||||
|
{
|
||||||
|
QString one;
|
||||||
|
typedef double DOUBLE;
|
||||||
|
};
|
||||||
|
|
||||||
|
void bla(int);
|
||||||
|
void bla(const QString &);
|
||||||
|
void bla(const QString &) const;
|
||||||
|
void bla(int, const QString &) const;
|
||||||
|
|
||||||
|
void foo(int) const {}
|
||||||
|
void foo(const QString &) const {}
|
||||||
|
|
||||||
|
QString one;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChildDummy : public Dummy {};
|
||||||
|
|
||||||
|
class GrandChildDummy : public Dummy {};
|
||||||
|
|
||||||
|
} // namespace test
|
||||||
|
|
||||||
|
#endif // DUMMY_H
|
||||||
175
tests/manual/cplusplus-tools/main.cpp
Normal file
175
tests/manual/cplusplus-tools/main.cpp
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
* Below are some basic test suggestions. Trying them in a larger
|
||||||
|
* project (Qt Creator, for example) is also valid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Folow includes
|
||||||
|
*/
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdio>
|
||||||
|
//#include <Windows.h>
|
||||||
|
//#include <linux/version.h>
|
||||||
|
#include "dummy.h"
|
||||||
|
#include "detail/header.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Complete includes
|
||||||
|
*/
|
||||||
|
//#include <QDe
|
||||||
|
//#include <QtCor
|
||||||
|
//#include <QtCore/QXmlStream
|
||||||
|
|
||||||
|
//#include <ios
|
||||||
|
//#include <vec
|
||||||
|
//#include <cstd
|
||||||
|
|
||||||
|
//#include <Win
|
||||||
|
//#include <lin
|
||||||
|
|
||||||
|
//#include "dum
|
||||||
|
//#include "deta
|
||||||
|
//#include "detail/hea
|
||||||
|
|
||||||
|
|
||||||
|
using namespace test;
|
||||||
|
|
||||||
|
int fi = 10;
|
||||||
|
extern int xi;
|
||||||
|
const int ci = 1;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
int ai = 100;
|
||||||
|
int afunc() {
|
||||||
|
return fi * xi + ai + ci;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Follow symbols
|
||||||
|
- Expect some issues when finding the best function overload and with templates.
|
||||||
|
- Try using a local namespace directive instead of the global one.
|
||||||
|
*/
|
||||||
|
using namespace test;
|
||||||
|
void testFollowSymbols()
|
||||||
|
{
|
||||||
|
//using namespace test;
|
||||||
|
|
||||||
|
Dummy dummy;
|
||||||
|
Dummy::sfunc();
|
||||||
|
Dummy::ONE;
|
||||||
|
Dummy::PI;
|
||||||
|
dummy.bla(fi);
|
||||||
|
dummy.bla("bla");
|
||||||
|
dummy.one = "one";
|
||||||
|
Dummy::Internal internal;
|
||||||
|
internal.one = "one";
|
||||||
|
Dummy::INT i;
|
||||||
|
Dummy::Values V;
|
||||||
|
Dummy::v1;
|
||||||
|
freefunc1();
|
||||||
|
freefunc2(10);
|
||||||
|
freefunc2("s");
|
||||||
|
freefunc3(dummy);
|
||||||
|
freefunc3(dummy, 10);
|
||||||
|
freefunc3(10, 10);
|
||||||
|
freefunc3(1.0);
|
||||||
|
afunc();
|
||||||
|
i;
|
||||||
|
V;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Complete symbols
|
||||||
|
- Check function arguments.
|
||||||
|
*/
|
||||||
|
void testCompleteSymbols()
|
||||||
|
{
|
||||||
|
test::Dummy dummy;
|
||||||
|
test::Dummy::Internal internal;
|
||||||
|
|
||||||
|
// in
|
||||||
|
// Dum
|
||||||
|
// Dummy::s
|
||||||
|
// Dummy::O
|
||||||
|
// Dummy::P
|
||||||
|
// dummy.
|
||||||
|
// dummy.b
|
||||||
|
// dummy.bla(
|
||||||
|
// dummy.o
|
||||||
|
// Dummy::In
|
||||||
|
// internal.o
|
||||||
|
// Dummy::Internal::
|
||||||
|
// freefunc2
|
||||||
|
// using namespace st
|
||||||
|
// afun
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Complete snippets
|
||||||
|
*/
|
||||||
|
void testCompleteSnippets()
|
||||||
|
{
|
||||||
|
// for
|
||||||
|
// class
|
||||||
|
// whil
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Find usages
|
||||||
|
- Go to other files for more options.
|
||||||
|
*/
|
||||||
|
void testFindUsages()
|
||||||
|
{
|
||||||
|
Dummy();
|
||||||
|
Dummy::sfunc();
|
||||||
|
Dummy::ONE;
|
||||||
|
xi;
|
||||||
|
fi;
|
||||||
|
ci;
|
||||||
|
ai;
|
||||||
|
afunc();
|
||||||
|
freefunc1();
|
||||||
|
freefunc2("s");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Rename
|
||||||
|
- Compile to make sure.
|
||||||
|
- Go to other files for more options.
|
||||||
|
*/
|
||||||
|
void testRename()
|
||||||
|
{
|
||||||
|
fi;
|
||||||
|
ci;
|
||||||
|
ai;
|
||||||
|
afunc();
|
||||||
|
testCompleteSnippets();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Type hierarchy
|
||||||
|
*/
|
||||||
|
void testTypeHierarchy()
|
||||||
|
{
|
||||||
|
test::GrandChildDummy();
|
||||||
|
D();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Switch declaration/definition
|
||||||
|
- Use methods from Dummy.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Switch header/source
|
||||||
|
- Use dummy.h and dummy.cpp.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user