diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-28 19:23:45 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-28 19:23:45 +0000 |
commit | 674274ed06dfdf9488e7f3bc9e3b45b9f7f4fb18 (patch) | |
tree | df88d2ee7f25614e16ce2df7c07ca191f1745ac8 /src/unitsuite.cpp | |
parent | 5b68b0c6abd98fc99acd57a2c5c691468e7dcb97 (diff) | |
download | libbu++-674274ed06dfdf9488e7f3bc9e3b45b9f7f4fb18.tar.gz libbu++-674274ed06dfdf9488e7f3bc9e3b45b9f7f4fb18.tar.bz2 libbu++-674274ed06dfdf9488e7f3bc9e3b45b9f7f4fb18.tar.xz libbu++-674274ed06dfdf9488e7f3bc9e3b45b9f7f4fb18.zip |
More myriad testing and unit test features, not unit tests that may take a
while are welcome to provide progress info with some builtin functions.
The Bu::Archive class now throws an exception if reading is interrupted by EOS
Diffstat (limited to '')
-rw-r--r-- | src/unitsuite.cpp | 41 |
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 | ||
14 | using namespace Bu; | 15 | using 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 | ||
191 | void 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 | |||
200 | void Bu::UnitSuite::setStepCount( int iSteps ) | ||
201 | { | ||
202 | iStepCount = iSteps; | ||
203 | if( iStepCount < 0 ) | ||
204 | return; | ||
205 | tLastUpdate = 0; | ||
206 | dispProgress(); | ||
207 | } | ||
208 | |||
209 | void 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 | |||
219 | void 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 | |||
188 | int Bu::UnitSuite::onListCases( StrArray ) | 229 | int Bu::UnitSuite::onListCases( StrArray ) |
189 | { | 230 | { |
190 | sio << "Test cases:" << sio.nl; | 231 | sio << "Test cases:" << sio.nl; |