Permalink
Browse files

use templated assert

  • Loading branch information...
1 parent a54742b commit 23936952c13e1bcc072accc4b8adfcae09de9cfe @erh erh committed Oct 8, 2009
Showing with 18 additions and 27 deletions.
  1. +1 −23 dbtests/framework.cpp
  2. +17 −4 dbtests/framework.h
View
@@ -324,30 +324,8 @@ namespace mongo {
log() << _file << ":" << _line << " " << _aexp << " != " << _bexp << " ";
}
- void MyAsserts::ae( double a , double b ){
+ void MyAsserts::_gotAssert(){
Result::cur->_asserts++;
- if ( a == b )
- return;
-
- printLocation();
-
- MyAssertionException * e = getBase();
- e->ss << a << " != " << b << endl;
- log() << e->ss.str() << endl;
- throw e;
- }
-
- void MyAsserts::ae( string a , string b ){
- Result::cur->_asserts++;
- if ( a == b )
- return;
-
- printLocation();
-
- MyAssertionException * e = getBase();
- e->ss << a << " != " << b << endl;
- log() << e->ss.str() << endl;
- throw e;
}
}
View
@@ -151,14 +151,27 @@ namespace mongo {
: _aexp( aexp ) , _bexp( bexp ) , _file( file ) , _line( line ){
}
-
- void ae( double a , double b );
- void ae( string a , string b );
+
+ template<typename A,typename B>
+ void ae( A a , B b ){
+ _gotAssert();
+ if ( a == b )
+ return;
+
+ printLocation();
+
+ MyAssertionException * e = getBase();
+ e->ss << a << " != " << b << endl;
+ log() << e->ss.str() << endl;
+ throw e;
+ }
void printLocation();
-
+
private:
+ void _gotAssert();
+
MyAssertionException * getBase();
string _aexp;

0 comments on commit 2393695

Please sign in to comment.