1 | program Main;
|
---|
2 |
|
---|
3 | uses
|
---|
4 | Classes,
|
---|
5 | SysUtils,
|
---|
6 | TestAssert,
|
---|
7 | CmdLineParameterUnitTests,
|
---|
8 | StringUtilsUnitTests,
|
---|
9 | FileUtilsUnitTests,
|
---|
10 | HelpTopicTests;
|
---|
11 |
|
---|
12 | IMPORTS
|
---|
13 | FUNCTION PmPrintfString(aString:PChar):BYTE; APIENTRY; 'PMPRINTF' NAME 'PmPrintfString';
|
---|
14 | END;
|
---|
15 |
|
---|
16 | VAR
|
---|
17 | tmpSuites : TList;
|
---|
18 | tmpTests : TList;
|
---|
19 | tmpAllTests : TList;
|
---|
20 | tmpAllExceptions : TStringList;
|
---|
21 | tmpFunction : FUNCTION : TList;
|
---|
22 | tmpTestNoParam : String;
|
---|
23 | tmpTest : PROCEDURE;
|
---|
24 | i,j,tmpTestCount,tmpFailureCount,tmpErrorCount,tmpTestNo : integer;
|
---|
25 | tmpStartTime, tmpEndTime : TDateTime;
|
---|
26 |
|
---|
27 | BEGIN
|
---|
28 | tmpAllTests := TList.Create;
|
---|
29 | tmpSuites := TList.Create;
|
---|
30 | tmpAllExceptions := TStringList.Create;
|
---|
31 |
|
---|
32 | tmpTestNoParam := ParamStr(1);
|
---|
33 | writeln(tmpTestNoParam);
|
---|
34 |
|
---|
35 | tmpSuites.Add(@getCmdLineParameterUnitTests);
|
---|
36 | tmpSuites.Add(@getStringUtilsUnitTests);
|
---|
37 | // tmpSuites.Add(@getHelpTopicTests);
|
---|
38 | tmpSuites.Add(@getFileUtilsUnitTests);
|
---|
39 |
|
---|
40 | tmpTestNo := -1;
|
---|
41 | try
|
---|
42 | tmpTestNo := StrToInt(tmpTestNoParam);
|
---|
43 | tmpTestNo := tmpTestNo;
|
---|
44 | // no parameter or empty
|
---|
45 | if 0 = tmpTestNo then tmpTestNo := -1;
|
---|
46 | except
|
---|
47 | end;
|
---|
48 |
|
---|
49 | tmpTestCount := 0;
|
---|
50 | tmpFailureCount := 0;
|
---|
51 | tmpErrorCount := 0;
|
---|
52 | tmpStartTime := now;
|
---|
53 |
|
---|
54 | for i := 0 to tmpSuites.Count-1 do
|
---|
55 | begin
|
---|
56 | tmpFunction := tmpSuites.items[i];
|
---|
57 | tmpTests := tmpFunction;
|
---|
58 |
|
---|
59 | for j := 0 to tmpTests.Count-1 do
|
---|
60 | begin
|
---|
61 | tmpTestCount := tmpTestCount + 1;
|
---|
62 | tmpTest := tmpTests.items[j];
|
---|
63 | if (0 > tmpTestNo)
|
---|
64 | OR (tmpTestNo = tmpTestCount)
|
---|
65 | then
|
---|
66 | begin
|
---|
67 | try
|
---|
68 | tmpTest;
|
---|
69 | Write('.');
|
---|
70 | except
|
---|
71 | on e:EAssertFailed do
|
---|
72 | begin
|
---|
73 | tmpFailureCount := tmpFailureCount + 1;
|
---|
74 | tmpAllExceptions.add('# ' + IntToStr(tmpTestCount) + ' ' + e.message);
|
---|
75 | end;
|
---|
76 | on e:Exception do
|
---|
77 | begin
|
---|
78 | tmpErrorCount := tmpErrorCount + 1;
|
---|
79 | tmpAllExceptions.add('# ' + IntToStr(tmpTestCount) + ' ' + e.message);
|
---|
80 | end;
|
---|
81 | end;
|
---|
82 | if (0 = tmpTestCount MOD 50) then writeln;
|
---|
83 | end;
|
---|
84 | end;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | tmpEndTime := now;
|
---|
88 |
|
---|
89 | writeln;
|
---|
90 | for i := 0 to tmpAllExceptions.count-1 do
|
---|
91 | begin
|
---|
92 | writeln(tmpAllExceptions[i]);
|
---|
93 | end;
|
---|
94 |
|
---|
95 | if (0 > tmpTestNo) then
|
---|
96 | write('Tests run: ' + IntToStr(tmpTestCount))
|
---|
97 | else
|
---|
98 | write('Test #' + IntToStr(tmpTestNo) + ':');
|
---|
99 | write(', Failures: ' + IntToStr(tmpFailureCount));
|
---|
100 | write(', Errors: ' + IntToStr(tmpErrorCount));
|
---|
101 | write(', Time elapsed: ' + FormatDateTime('hh:nn:ss', tmpEndTime - tmpStartTime));
|
---|
102 | writeln;
|
---|
103 |
|
---|
104 | END.
|
---|