-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestRunner.mqh
39 lines (33 loc) · 1.17 KB
/
TestRunner.mqh
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
//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2020, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
#property strict
/// Singleton used to keep track of tests
class TestRunner {
public:
static TestRunner* Current;
int testCount;
int testFailedCount;
TestRunner()
: testCount(0), testFailedCount(0) {
Current = GetPointer(this);
}
~TestRunner() {
PrintFormat("Test run summary: %u / %u passed", testCount - testFailedCount, testCount);
if (testFailedCount > 0) {
Alert(testFailedCount, " test(s) failed");
}
};
};
TestRunner *TestRunner::Current = NULL;
/// Static method to be used in tests
void Assert(bool condition) {
TestRunner *t = TestRunner::Current;
t.testCount++;
if (!condition) {
t.testFailedCount++;
}
};
//+------------------------------------------------------------------+