source: trunk/NewView/unittests/NewViewTests.pas@ 82

Last change on this file since 82 was 82, checked in by RBRi, 19 years ago

file util refactoring and many more unit tests

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