Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- // Here begins the framework header
- int register_test(const char *name, void (*ptr)());
- #define STRINGIFY(s) #s
- // NOTE: The trick below, initializing a constant with an expression, doesn't work in C.
- // It works in C++ BUT the order of initialization is undefined. It's possible to maintain a
- // counter in a macro variable (e.g. Boost preprocessor does this),
- // or one could just run the tests in alphabetical order if one is lazy.
- #define TEST(name) \
- static void name(); \
- static int name ## _registration = register_test(STRINGIFY(name), &name); \
- static void name()
- // Here begins the framework implementation
- int register_test(const char *name, void (*ptr)())
- {
- printf("Adding test %s (%p) to global list.\n", name, ptr);
- /* TODO */
- return 0; // Dummy return
- }
- // Here ends the framework
- TEST(my_test) {
- printf("trololoo\n");
- }
- int main()
- {
- /* run_all_tests(); */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement