Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
123eb257
Commit
123eb257
authored
10 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
use path to select up to single class of test
parent
8de2be73
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2algo/test-src/main.cpp
+31
-21
31 additions, 21 deletions
alib2algo/test-src/main.cpp
alib2data/test-src/main.cpp
+17
-7
17 additions, 7 deletions
alib2data/test-src/main.cpp
with
48 additions
and
28 deletions
alib2algo/test-src/main.cpp
+
31
−
21
View file @
123eb257
...
...
@@ -21,30 +21,30 @@ CPPUNIT_NS_BEGIN
class
CPPUNIT_API
TestProgressListener
:
public
TestListener
{
public:
TestProgressListener
();
TestProgressListener
();
virtual
~
TestProgressListener
();
virtual
~
TestProgressListener
();
void
startTest
(
Test
*
test
);
void
startTest
(
Test
*
test
);
void
addFailure
(
const
TestFailure
&
failure
);
void
addFailure
(
const
TestFailure
&
failure
);
void
endTest
(
Test
*
test
);
void
endTest
(
Test
*
test
);
int
getResult
()
const
;
int
getResult
()
const
;
void
printResults
()
const
;
void
printResults
()
const
;
private:
TestProgressListener
(
const
TestProgressListener
&
copy
);
TestProgressListener
(
const
TestProgressListener
&
copy
);
void
operator
=
(
const
TestProgressListener
&
copy
);
void
operator
=
(
const
TestProgressListener
&
copy
);
private:
int
m_Failures
;
int
m_Tests
;
int
m_Assertions
;
bool
m_lastTestFailed
;
int
m_Failures
;
int
m_Tests
;
int
m_Assertions
;
bool
m_lastTestFailed
;
};
TestProgressListener
::
TestProgressListener
()
:
m_Failures
(
0
),
m_Tests
(
0
),
m_Assertions
(
0
),
m_lastTestFailed
(
false
)
...
...
@@ -79,7 +79,7 @@ void TestProgressListener::endTest( Test * test)
stdCOut
().
flush
();
if
(
!
m_lastTestFailed
)
stdCOut
()
<<
" : OK"
;
stdCOut
()
<<
" : OK"
;
else
stdCOut
()
<<
" : Fail"
;
stdCOut
()
<<
"
\n\n
"
;
...
...
@@ -99,8 +99,8 @@ int main(int argc, char* argv[]) {
try
{
TCLAP
::
CmdLine
cmd
(
"Main test binary."
,
' '
,
"0.01"
);
TCLAP
::
MultiArg
<
std
::
string
>
testPath
(
"p"
,
"path"
,
"test path"
,
false
,
"string"
);
cmd
.
add
(
testPath
);
TCLAP
::
MultiArg
<
std
::
string
>
testPath
Segments
(
"p"
,
"path"
,
"test path"
,
false
,
"string"
);
cmd
.
add
(
testPath
Segments
);
cmd
.
parse
(
argc
,
argv
);
...
...
@@ -113,13 +113,23 @@ int main(int argc, char* argv[]) {
controller
.
addListener
(
&
progressListener
);
CppUnit
::
Test
*
suite
=
NULL
;
if
(
testPath
.
getValue
().
size
()
==
0
)
{
std
::
string
testPath
=
""
;
if
(
testPathSegments
.
getValue
().
size
()
==
0
)
{
// Get the top level suite from the registry
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
();
}
else
if
(
testPath
.
getValue
().
size
()
==
1
)
{
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPath
.
getValue
()[
0
]).
makeTest
();
}
else
if
(
testPath
Segments
.
getValue
().
size
()
==
1
)
{
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPath
Segments
.
getValue
()[
0
]).
makeTest
();
}
else
{
throw
TCLAP
::
ArgException
(
"too many arguments in path switch"
);
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPathSegments
.
getValue
()[
0
]).
makeTest
();
bool
first
=
true
;
for
(
const
std
::
string
&
path
:
testPathSegments
.
getValue
())
{
if
(
first
)
{
first
=
false
;
continue
;
}
testPath
+=
path
+
"/"
;
}
testPath
.
pop_back
();
}
// Adds the test to the list of test to run
...
...
@@ -129,7 +139,7 @@ int main(int argc, char* argv[]) {
// Change the default outputter to a compiler error format outputter
runner
.
setOutputter
(
new
CppUnit
::
CompilerOutputter
(
&
runner
.
result
(),
std
::
cerr
)
);
// Run the tests.
runner
.
run
(
controller
);
runner
.
run
(
controller
,
testPath
);
progressListener
.
printResults
();
...
...
This diff is collapsed.
Click to expand it.
alib2data/test-src/main.cpp
+
17
−
7
View file @
123eb257
...
...
@@ -99,8 +99,8 @@ int main(int argc, char* argv[]) {
try
{
TCLAP
::
CmdLine
cmd
(
"Main test binary."
,
' '
,
"0.01"
);
TCLAP
::
MultiArg
<
std
::
string
>
testPath
(
"p"
,
"path"
,
"test path"
,
false
,
"string"
);
cmd
.
add
(
testPath
);
TCLAP
::
MultiArg
<
std
::
string
>
testPath
Segments
(
"p"
,
"path"
,
"test path"
,
false
,
"string"
);
cmd
.
add
(
testPath
Segments
);
cmd
.
parse
(
argc
,
argv
);
...
...
@@ -113,13 +113,23 @@ int main(int argc, char* argv[]) {
controller
.
addListener
(
&
progressListener
);
CppUnit
::
Test
*
suite
=
NULL
;
if
(
testPath
.
getValue
().
size
()
==
0
)
{
std
::
string
testPath
=
""
;
if
(
testPathSegments
.
getValue
().
size
()
==
0
)
{
// Get the top level suite from the registry
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
();
}
else
if
(
testPath
.
getValue
().
size
()
==
1
)
{
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPath
.
getValue
()[
0
]).
makeTest
();
}
else
if
(
testPath
Segments
.
getValue
().
size
()
==
1
)
{
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPath
Segments
.
getValue
()[
0
]).
makeTest
();
}
else
{
throw
TCLAP
::
ArgException
(
"too many arguments in path switch"
);
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
(
testPathSegments
.
getValue
()[
0
]).
makeTest
();
bool
first
=
true
;
for
(
const
std
::
string
&
path
:
testPathSegments
.
getValue
())
{
if
(
first
)
{
first
=
false
;
continue
;
}
testPath
+=
path
+
"/"
;
}
testPath
.
pop_back
();
}
// Adds the test to the list of test to run
...
...
@@ -129,7 +139,7 @@ int main(int argc, char* argv[]) {
// Change the default outputter to a compiler error format outputter
runner
.
setOutputter
(
new
CppUnit
::
CompilerOutputter
(
&
runner
.
result
(),
std
::
cerr
)
);
// Run the tests.
runner
.
run
(
controller
);
runner
.
run
(
controller
,
testPath
);
progressListener
.
printResults
();
...
...
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