forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
165 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef CPP2_TESTING_H | ||
#define CPP2_TESTING_H | ||
|
||
namespace cpp2::testing { | ||
|
||
using test_function = void(void); | ||
|
||
class session { | ||
public: | ||
session() { | ||
std::cout << "Creating test session!\n"; | ||
} | ||
|
||
static inline session& the() { | ||
static session instance; | ||
return instance; | ||
} | ||
|
||
void register_test(test_function* tf) { | ||
tests_.push_back(tf); | ||
} | ||
|
||
void run(int const argc, char** argv) { | ||
std::cout << "Running test session!\n"; | ||
int test_count = 0; | ||
for(auto test : tests_) { | ||
std::cout << "Running test " << test_count++ << "!\n"; | ||
test(); | ||
} | ||
} | ||
private: | ||
std::vector<test_function*> tests_; | ||
}; | ||
|
||
struct auto_reg { | ||
auto_reg(test_function* tf) { | ||
std::cout << "Registering test func: " << tf << '\n'; | ||
session::the().register_test(tf); | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif |
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
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
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
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