source: trunk/unittests/NewViewTests.pas@ 384

Last change on this file since 384 was 384, checked in by RBRi, 9 years ago

move the unit test to a more central place

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