diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
| commit | ac517a2b7625e0aa0862679e961c6349f859ea3b (patch) | |
| tree | e3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/unitsuite.cpp | |
| parent | f8d4301e9fa4f3709258505941e37fab2eadadc6 (diff) | |
| parent | bd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff) | |
| download | libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2 libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip | |
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to 'src/unitsuite.cpp')
| -rw-r--r-- | src/unitsuite.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/unitsuite.cpp b/src/unitsuite.cpp new file mode 100644 index 0000000..2a28eb5 --- /dev/null +++ b/src/unitsuite.cpp | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #include "unitsuite.h" | ||
| 2 | |||
| 3 | Bu::UnitSuite::UnitSuite() | ||
| 4 | { | ||
| 5 | } | ||
| 6 | |||
| 7 | Bu::UnitSuite::~UnitSuite() | ||
| 8 | { | ||
| 9 | } | ||
| 10 | |||
| 11 | int Bu::UnitSuite::run( int argc, char *argv[] ) | ||
| 12 | { | ||
| 13 | for( TestList::iterator i = lTests.begin(); i != lTests.end(); i++ ) | ||
| 14 | { | ||
| 15 | printf("%s: ", i->sName.getStr() ); | ||
| 16 | fflush( stdout ); | ||
| 17 | try | ||
| 18 | { | ||
| 19 | (this->*(i->fTest))(); | ||
| 20 | printf("passed.\n"); | ||
| 21 | } | ||
| 22 | catch( Failed &e ) | ||
| 23 | { | ||
| 24 | if( e.bFile ) | ||
| 25 | { | ||
| 26 | printf("unitTest(%s) failed. (%s:%d)\n", | ||
| 27 | e.str.getStr(), | ||
| 28 | e.sFile.getStr(), | ||
| 29 | e.nLine | ||
| 30 | ); | ||
| 31 | } | ||
| 32 | else | ||
| 33 | { | ||
| 34 | printf("unitTest(%s) failed.\n", | ||
| 35 | e.str.getStr() | ||
| 36 | ); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | catch( ... ) | ||
| 40 | { | ||
| 41 | printf("failed with external exception.\n"); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | return 0; | ||
| 46 | } | ||
| 47 | |||
| 48 | void Bu::UnitSuite::add( Test fTest, Bu::FString sName ) | ||
| 49 | { | ||
| 50 | TestInfo ti; | ||
| 51 | ti.sName = sName; | ||
| 52 | long index = ti.sName.rfind("::"); | ||
| 53 | if( index != -1 ) | ||
| 54 | { | ||
| 55 | FString tmp = sSuiteName; | ||
| 56 | tmp += ti.sName.getStr()+index; | ||
| 57 | ti.sName = tmp; | ||
| 58 | } | ||
| 59 | ti.fTest = fTest; | ||
| 60 | lTests.push_back( ti ); | ||
| 61 | } | ||
| 62 | |||
| 63 | void Bu::UnitSuite::setName( const FString &sName ) | ||
| 64 | { | ||
| 65 | sSuiteName = sName; | ||
| 66 | } | ||
| 67 | |||
