Created
December 26, 2014 11:16
-
-
Save martinmoene/59450eaa1371f7c25210 to your computer and use it in GitHub Desktop.
Spread lest tests over multiple files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 - use multiple source files. | |
#include "lest.hpp" | |
lest::tests & specifications() | |
{ | |
static lest::tests tests; | |
return tests; | |
} | |
int main( int argc, char * argv[] ) | |
{ | |
return lest::run( specifications(), lest::texts( argv + 1, argv + argc ) /*, std::cout */ ); | |
} | |
// cl -nologo -W3 -EHsc -I.. -Felest-module.exe lest-module-1.cpp lest-module-2.cpp lest-module-3.cpp && lest-module | |
// g++ -Wall -Wextra -std=c++11 -I.. -o lest-module.exe lest-module-1.cpp lest-module-2.cpp lest-module-3.cpp && lest-module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 - use multiple source files. | |
#include "lest.hpp" | |
#include "lest-module.hpp" | |
const lest::test module[] = { | |
CASE( "A passing test" "[pass]" ) | |
{ | |
EXPECT( 42 == 42 ); | |
} | |
}; | |
extern lest::tests & specifications(); | |
lest_ADD_MODULE( specifications(), module ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 - use multiple source files. | |
#include "lest.hpp" | |
#include "lest-module.hpp" | |
const lest::test module[] = { | |
CASE( "A failing test" "[fail]" ) | |
{ | |
EXPECT( 42 == 7 ); | |
} | |
}; | |
extern lest::tests & specifications(); | |
lest_ADD_MODULE( specifications(), module ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++11 - use multiple source files. | |
#include "lest.hpp" | |
#define lest_ADD_MODULE( collection, module ) \ | |
namespace { lest::module_registrar _( collection, module ); } | |
namespace lest { | |
struct module_registrar | |
{ | |
template <std::size_t N> | |
module_registrar( lest::tests & collection, test const (&module)[N] ) | |
{ | |
collection.insert( collection.end(), std::begin( module ), std::end( module ) ); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment