source: trunk/unittests/NewViewTests.pas@ 224

Last change on this file since 224 was 224, checked in by RBRi, 18 years ago

% refactoring

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