Advertisement
Guest User

trax

a guest
Apr 3rd, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <vector>
  3.  
  4. typedef void (*TestFunction)();
  5. static std::vector<TestFunction>collectionOfTestFunction;
  6.  
  7. int registerFunction(TestFunction f){
  8.   collectionOfTestFunction.push_back(f);
  9.   return 1;
  10. }
  11.  
  12. #define ADD_TEST(TEST_NAME) void test_##TEST_NAME(void);        \
  13.   static int t_##TEST_NAME = registerFunction(test_##TEST_NAME);    \
  14.   void test_##TEST_NAME (void)
  15.  
  16. ADD_TEST(SimpleTest){
  17.   printf("my test\n");
  18. }
  19.  
  20. int main(int argc, char *argv[]) {
  21.   for (auto f : collectionOfTestFunction){
  22.     f();
  23.   }
  24.  
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement