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
f717d7a1
Commit
f717d7a1
authored
10 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
Better test result output
parent
c7514922
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
alib2/test-src/main.cpp
+84
-3
84 additions, 3 deletions
alib2/test-src/main.cpp
with
84 additions
and
3 deletions
alib2/test-src/main.cpp
+
84
−
3
View file @
f717d7a1
...
@@ -2,10 +2,92 @@
...
@@ -2,10 +2,92 @@
#include
<cppunit/CompilerOutputter.h>
#include
<cppunit/CompilerOutputter.h>
#include
<cppunit/extensions/TestFactoryRegistry.h>
#include
<cppunit/extensions/TestFactoryRegistry.h>
#include
<cppunit/ui/text/TestRunner.h>
#include
<cppunit/ui/text/TestRunner.h>
#include
<cppunit/TestResultCollector.h>
#include
<cppunit/TestResult.h>
#include
<cppunit/Test.h>
#include
<cppunit/TestFailure.h>
#include
<cppunit/portability/Stream.h>
#include
<cppunit/TestListener.h>
CPPUNIT_NS_BEGIN
class
CPPUNIT_API
TestProgressListener
:
public
TestListener
{
public:
TestProgressListener
();
virtual
~
TestProgressListener
();
void
startTest
(
Test
*
test
);
void
addFailure
(
const
TestFailure
&
failure
);
void
endTest
(
Test
*
test
);
int
getResult
()
const
;
private:
TestProgressListener
(
const
TestProgressListener
&
copy
);
void
operator
=
(
const
TestProgressListener
&
copy
);
private:
int
m_Result
;
bool
m_lastTestFailed
;
};
TestProgressListener
::
TestProgressListener
()
:
m_Result
(
0
),
m_lastTestFailed
(
false
)
{
}
TestProgressListener
::~
TestProgressListener
()
{
}
void
TestProgressListener
::
startTest
(
Test
*
test
)
{
stdCOut
()
<<
test
->
getName
()
<<
":
\n
"
;
stdCOut
().
flush
();
m_lastTestFailed
=
false
;
}
void
TestProgressListener
::
addFailure
(
const
TestFailure
&
failure
)
{
stdCOut
()
<<
" : "
<<
(
failure
.
isError
()
?
"error"
:
"assertion"
);
m_lastTestFailed
=
true
;
m_Result
++
;
}
void
TestProgressListener
::
endTest
(
Test
*
test
)
{
stdCOut
()
<<
"Result ("
<<
test
->
getName
()
<<
"):"
;
stdCOut
().
flush
();
if
(
!
m_lastTestFailed
)
stdCOut
()
<<
" : OK"
;
else
stdCOut
()
<<
" : Fail"
;
stdCOut
()
<<
"
\n\n
"
;
}
int
TestProgressListener
::
getResult
()
const
{
return
m_Result
;
}
CPPUNIT_NS_END
int
main
(
int
,
char
*
[])
int
main
(
int
,
char
*
[])
{
{
CppUnit
::
TestResult
controller
;
CppUnit
::
TestResultCollector
result
;
controller
.
addListener
(
&
result
);
CppUnit
::
TestProgressListener
progressListener
;
controller
.
addListener
(
&
progressListener
);
// Get the top level suite from the registry
// Get the top level suite from the registry
CppUnit
::
Test
*
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
();
CppUnit
::
Test
*
suite
=
CppUnit
::
TestFactoryRegistry
::
getRegistry
().
makeTest
();
...
@@ -17,8 +99,7 @@ int main(int , char*[])
...
@@ -17,8 +99,7 @@ int main(int , char*[])
runner
.
setOutputter
(
new
CppUnit
::
CompilerOutputter
(
&
runner
.
result
(),
runner
.
setOutputter
(
new
CppUnit
::
CompilerOutputter
(
&
runner
.
result
(),
std
::
cerr
)
);
std
::
cerr
)
);
// Run the tests.
// Run the tests.
bool
wasSucessful
=
runner
.
run
(
);
runner
.
run
(
controller
);
// Return error code 1 if the one of test failed.
return
progressListener
.
getResult
();
return
wasSucessful
?
0
:
1
;
}
}
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