summaryrefslogtreecommitdiff
path: root/src/unitsuite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unitsuite.cpp')
-rw-r--r--src/unitsuite.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/unitsuite.cpp b/src/unitsuite.cpp
index 0a531c0..7a20128 100644
--- a/src/unitsuite.cpp
+++ b/src/unitsuite.cpp
@@ -10,6 +10,7 @@
10#include "bu/sio.h" 10#include "bu/sio.h"
11#include "bu/optparser.h" 11#include "bu/optparser.h"
12#include <stdlib.h> 12#include <stdlib.h>
13#include <time.h>
13 14
14using namespace Bu; 15using namespace Bu;
15 16
@@ -53,6 +54,8 @@ int Bu::UnitSuite::run( int argc, char *argv[] )
53 << sio.flush; 54 << sio.flush;
54 try 55 try
55 { 56 {
57 iStepCount = -1;
58 iProgress = 0;
56 (this->*(i->fTest))(); 59 (this->*(i->fTest))();
57 switch( i->eExpect ) 60 switch( i->eExpect )
58 { 61 {
@@ -185,6 +188,44 @@ void Bu::UnitSuite::setName( const FString &sName )
185 sSuiteName = sName; 188 sSuiteName = sName;
186} 189}
187 190
191void Bu::UnitSuite::dispProgress()
192{
193 if( tLastUpdate == time( NULL ) )
194 return;
195 sio << Fmt(3) << (iProgress*100/iStepCount) << "%" << "\b\b\b\b"
196 << sio.flush;
197 tLastUpdate = time( NULL );
198}
199
200void Bu::UnitSuite::setStepCount( int iSteps )
201{
202 iStepCount = iSteps;
203 if( iStepCount < 0 )
204 return;
205 tLastUpdate = 0;
206 dispProgress();
207}
208
209void Bu::UnitSuite::incProgress( int iAmnt )
210{
211 iProgress += iAmnt;
212 if( iProgress < 0 )
213 iProgress = 0;
214 if( iProgress > iStepCount )
215 iProgress = iStepCount;
216 dispProgress();
217}
218
219void Bu::UnitSuite::setProgress( int iAmnt )
220{
221 iProgress = iAmnt;
222 if( iProgress < 0 )
223 iProgress = 0;
224 if( iProgress > iStepCount )
225 iProgress = iStepCount;
226 dispProgress();
227}
228
188int Bu::UnitSuite::onListCases( StrArray ) 229int Bu::UnitSuite::onListCases( StrArray )
189{ 230{
190 sio << "Test cases:" << sio.nl; 231 sio << "Test cases:" << sio.nl;