source: branches/2.20_branch/unittests/NewViewTests.pas

Last change on this file was 347, checked in by RBRi, 16 years ago

copyright change

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