Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
e43e09ee
Commit
e43e09ee
authored
16 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Test the pretty printer.
parent
26c81c54
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/manual/cplusplus/main.cpp
+44
-8
44 additions, 8 deletions
tests/manual/cplusplus/main.cpp
with
44 additions
and
8 deletions
tests/manual/cplusplus/main.cpp
+
44
−
8
View file @
e43e09ee
...
...
@@ -37,13 +37,18 @@
#include
<Scope.h>
#include
<Semantic.h>
#include
<TranslationUnit.h>
#include
<PrettyPrinter.h>
#include
<QtCore/QFile>
#include
<QtCore/QList>
#include
<QFile>
#include
<QList>
#include
<QCoreApplication>
#include
<QStringList>
#include
<QFileInfo>
#include
<QtDebug>
#include
<cstdio>
#include
<cstdlib>
#include
<iostream>
class
Rewrite
{
...
...
@@ -191,8 +196,35 @@ protected:
}
};
int
main
(
int
,
char
*
[])
int
main
(
int
argc
,
char
*
argv
[])
{
QCoreApplication
app
(
argc
,
argv
);
QStringList
args
=
app
.
arguments
();
const
QString
appName
=
args
.
first
();
args
.
removeFirst
();
bool
test_rewriter
=
false
;
bool
test_pretty_printer
=
false
;
foreach
(
QString
arg
,
args
)
{
if
(
arg
==
QLatin1String
(
"--test-rewriter"
))
test_rewriter
=
true
;
else
if
(
arg
==
QLatin1String
(
"--test-pretty-printer"
))
test_pretty_printer
=
true
;
else
if
(
arg
==
QLatin1String
(
"--help"
))
{
const
QFileInfo
appInfo
(
appName
);
const
QByteArray
appFileName
=
QFile
::
encodeName
(
appInfo
.
fileName
());
printf
(
"Usage: %s [options]
\n
"
" --help Display ths information
\n
"
" --test-rewriter Test the tree rewriter
\n
"
" --test-pretty-printer Test the pretty printer
\n
"
,
appFileName
.
constData
());
return
EXIT_SUCCESS
;
}
}
QFile
in
;
if
(
!
in
.
open
(
stdin
,
QFile
::
ReadOnly
))
return
EXIT_FAILURE
;
...
...
@@ -217,10 +249,14 @@ int main(int, char *[])
}
// test the rewriter
QByteArray
out
;
SimpleRefactor
refactor
(
&
control
);
refactor
(
&
unit
,
source
,
&
out
);
printf
(
"%s
\n
"
,
out
.
constData
());
if
(
test_rewriter
)
{
QByteArray
out
;
SimpleRefactor
refactor
(
&
control
);
refactor
(
&
unit
,
source
,
&
out
);
printf
(
"%s
\n
"
,
out
.
constData
());
}
else
if
(
test_pretty_printer
)
{
PrettyPrinter
pp
(
&
control
,
std
::
cout
);
pp
(
unit
.
ast
());
}
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment