Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Created February 19, 2017 00:10
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/5fd9e61635f6cb08bb7eba60c1ff850e to your computer and use it in GitHub Desktop.
Save JayBazuzi/5fd9e61635f6cb08bb7eba60c1ff850e to your computer and use it in GitHub Desktop.
#define Example(name, body) Example_(name, body, __COUNTER__)
#define Example_(name, body, counter) Example__(name, body, counter)
#define Example__(name, body, counter) \
struct ExampleInitializer##counter \
{ \
ExampleInitializer##counter() \
{ \
allExamples.Add({__FILE__, name, body}); \
} \
} ExampleInitializer##counter##Instance; \
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