Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Created February 19, 2017 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayBazuzi/f348f7a95719e78a75d91e65d97f79ad to your computer and use it in GitHub Desktop.
Save JayBazuzi/f348f7a95719e78a75d91e65d97f79ad to your computer and use it in GitHub Desktop.
#define Example(name) Example_(name, __COUNTER__)
#define Example_(name, counter) Example__(name, counter)
#define Example__(name, counter) \
void Example##counter(); \
struct ExampleInitializer##counter \
{ \
ExampleInitializer##counter() \
{ \
allExamples.Add({__FILE__, name, Example##counter}); \
} \
} ExampleInitializer##counter##Instance; \
void Example##counter()
Example("it multiplies two numbers")
{
auto testSubject = Calculator();
auto result = testSubject.Multiply(6, 9);
Assert(result == 42);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment