summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stable/unitsuite.cpp20
-rw-r--r--src/stable/unitsuite.h4
-rw-r--r--src/unit/file.unit4
-rw-r--r--src/unit/variant.unit2
4 files changed, 28 insertions, 2 deletions
diff --git a/src/stable/unitsuite.cpp b/src/stable/unitsuite.cpp
index db930a4..e508c6f 100644
--- a/src/stable/unitsuite.cpp
+++ b/src/stable/unitsuite.cpp
@@ -32,7 +32,6 @@ Bu::UnitSuite::~UnitSuite()
32{ 32{
33} 33}
34 34
35// Argument handling is coming soon, I promise.
36int Bu::UnitSuite::run( int argc, char *argv[] ) 35int Bu::UnitSuite::run( int argc, char *argv[] )
37{ 36{
38 bool bCleanup = true; 37 bool bCleanup = true;
@@ -41,9 +40,22 @@ int Bu::UnitSuite::run( int argc, char *argv[] )
41 "List available test cases." ); 40 "List available test cases." );
42 p.addOption( bCleanup, "no-cleanup", "Don't erase temp files."); 41 p.addOption( bCleanup, "no-cleanup", "Don't erase temp files.");
43 p.setOverride( "no-cleanup", false ); 42 p.setOverride( "no-cleanup", false );
43 p.setNonOption( Bu::slot( this, &Bu::UnitSuite::onAddTest ) );
44 p.addHelpOption(); 44 p.addHelpOption();
45 p.parse( argc, argv ); 45 p.parse( argc, argv );
46 46
47 if( !hSelTests.isEmpty() )
48 {
49 TestList lSub;
50 for( TestList::iterator i = lTests.begin(); i != lTests.end(); i++ )
51 {
52 if( hSelTests.has( (*i).sName ) )
53 lSub.append( *i );
54 }
55
56 lTests = lSub;
57 }
58
47 int iEPass = 0; 59 int iEPass = 0;
48 int iEFail = 0; 60 int iEFail = 0;
49 int iUPass = 0; 61 int iUPass = 0;
@@ -239,6 +251,12 @@ int Bu::UnitSuite::onListCases( StrArray )
239 return 0; 251 return 0;
240} 252}
241 253
254int Bu::UnitSuite::onAddTest( StrArray aParam )
255{
256 hSelTests.insert( aParam[0], true );
257 return 0;
258}
259
242Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e ) 260Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e )
243{ 261{
244 switch( e ) 262 switch( e )
diff --git a/src/stable/unitsuite.h b/src/stable/unitsuite.h
index 2250a4d..6915fb4 100644
--- a/src/stable/unitsuite.h
+++ b/src/stable/unitsuite.h
@@ -13,6 +13,7 @@
13#include "bu/string.h" 13#include "bu/string.h"
14#include "bu/file.h" 14#include "bu/file.h"
15#include "bu/array.h" 15#include "bu/array.h"
16#include "bu/hash.h"
16 17
17namespace Bu 18namespace Bu
18{ 19{
@@ -103,6 +104,7 @@ namespace Bu
103 104
104 private: 105 private:
105 int onListCases( Bu::Array<Bu::String> aParam ); 106 int onListCases( Bu::Array<Bu::String> aParam );
107 int onAddTest( Bu::Array<Bu::String> aParam );
106 108
107 private: 109 private:
108 typedef struct TestInfo 110 typedef struct TestInfo
@@ -124,6 +126,8 @@ namespace Bu
124 int iStepCount; 126 int iStepCount;
125 int iProgress; 127 int iProgress;
126 time_t tLastUpdate; 128 time_t tLastUpdate;
129
130 Bu::Hash<Bu::String, bool> hSelTests;
127 }; 131 };
128 132
129Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e ); 133Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e );
diff --git a/src/unit/file.unit b/src/unit/file.unit
index fb04e57..efca4f1 100644
--- a/src/unit/file.unit
+++ b/src/unit/file.unit
@@ -48,7 +48,11 @@ suite File
48 if( s < 50 ) 48 if( s < 50 )
49 { 49 {
50 unitTest( total == 256 ); 50 unitTest( total == 256 );
51 unitTest( sf.isEos() == false );
52 unitTest( sf.read( buf, 1 ) == 0 );
51 unitTest( sf.isEos() == true ); 53 unitTest( sf.isEos() == true );
54 // EOS is only set when an attempt to read past the end of
55 // the stream is made, not when a short block is returned.
52 break; 56 break;
53 } 57 }
54 } 58 }
diff --git a/src/unit/variant.unit b/src/unit/variant.unit
index 4fd5e26..53abdc0 100644
--- a/src/unit/variant.unit
+++ b/src/unit/variant.unit
@@ -55,7 +55,7 @@ suite Variant
55 arg( mkastring().getStr() ). 55 arg( mkastring().getStr() ).
56 arg( i1, Fmt(2).fill('0') ). 56 arg( i1, Fmt(2).fill('0') ).
57 arg( i2, Fmt(2).fill('0') ); 57 arg( i2, Fmt(2).fill('0') );
58 sio << sio.nl << out << sio.nl; 58 // sio << sio.nl << out << sio.nl;
59 unitTest( out == "hello-stuff-32-00.odp" ); 59 unitTest( out == "hello-stuff-32-00.odp" );
60 } 60 }
61} 61}