-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUnitTest.cpp
60 lines (51 loc) · 881 Bytes
/
UnitTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "UnitTest.h"
#include <cstdio>
namespace mg {
namespace unittests {
MG_STRFORMAT_PRINTF(1, 2)
void
Report(
const char *aFormat,
...)
{
va_list va;
va_start(va, aFormat);
ReportV(aFormat, va);
va_end(va);
}
MG_STRFORMAT_PRINTF(1, 0)
void
ReportV(
const char *aFormat,
va_list aArg)
{
vprintf(aFormat, aArg);
printf("\n");
}
TestSuiteGuard::TestSuiteGuard(
const char* aName)
{
Report("======== [%s] start", aName);
myTimer.Start();
}
TestSuiteGuard::~TestSuiteGuard()
{
Report("======== took %.6lf ms", myTimer.GetMilliSeconds());
}
MG_STRFORMAT_PRINTF(2, 3)
TestCaseGuard::TestCaseGuard(
const char* aFormat,
...)
{
va_list va;
va_start(va, aFormat);
ReportV(aFormat, va);
va_end(va);
myTimer.Start();
}
TestCaseGuard::~TestCaseGuard()
{
Report("took %.6lf ms", myTimer.GetMilliSeconds());
}
}
}