Skip to content

Commit

Permalink
Merge pull request #264 from kennytm/bug5587_unittestWithLine
Browse files Browse the repository at this point in the history
Bug 5587: Give unit test name by __LINE__.
  • Loading branch information
WalterBright committed Sep 6, 2012
2 parents 6a8be06 + af9cd30 commit d3669f7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/func.c
Expand Up @@ -3950,13 +3950,21 @@ void InvariantDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
* instances per module.
*/

static Identifier *unitTestId()
#if __DMC__ || _MSC_VER
#define snprintf _snprintf
#endif
static Identifier *unitTestId(Loc loc)
{
return Lexer::uniqueId("__unittest");
char name[24];
snprintf(name, 24, "__unittestL%u_", loc.linnum);
return Lexer::uniqueId(name);
}
#if __DMC__ || _MSC_VER
#undef snprintf
#endif

UnitTestDeclaration::UnitTestDeclaration(Loc loc, Loc endloc)
: FuncDeclaration(loc, endloc, unitTestId(), STCundefined, NULL)
: FuncDeclaration(loc, endloc, unitTestId(loc), STCundefined, NULL)
{
}

Expand Down

0 comments on commit d3669f7

Please sign in to comment.