source: cprs/branches/tmg-cprs/BDK32/Source/uUnitTestMFunStr.pas@ 1226

Last change on this file since 1226 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 4.1 KB
Line 
1{ **************************************************************
2 Package: XWB - Kernel RPCBroker
3 Date Created: Sept 18, 1997 (Version 1.1)
4 Site Name: Oakland, OI Field Office, Dept of Veteran Affairs
5 Developers: Joel Ivey
6 Description: Unit testing MFunStr code - requires dUnit for
7 unit testing.
8 Current Release: Version 1.1 Patch 40 (January 7, 2005))
9*************************************************************** }
10
11unit uUniTTestMFunStr;
12
13interface
14
15uses
16 TestFramework, Sgnoncnf, Classes, Graphics, SysUtils, Forms;
17
18type
19 TTestType = class(TTestCase)
20 private
21 // any private fields needed for processing
22 protected
23 // procedure SetUp; override;
24 // procedure TearDown; override;
25 published
26 // procedure TestName1;
27 // procedure TestName2;
28 end;
29
30 TTestMFunStr1 = class(TTestCase)
31 private
32 protected
33 procedure Setup; override;
34 public
35 published
36 procedure TestPiece1;
37 procedure TestPiece2;
38 procedure TestPiece3;
39 procedure TestPiece4;
40 procedure TestPiece5;
41 procedure TestPiece6;
42 procedure TestPiece7;
43 procedure TestPiece8;
44 procedure TestPiece9;
45 end;
46
47 TTestMFunStr2 = class(TTestCase)
48 protected
49 procedure Setup; override;
50 published
51 procedure TestTran1;
52 procedure TestTran2;
53 procedure TestTran3;
54 procedure TestTran4;
55 end;
56
57implementation
58
59uses
60 MFunStr_1;
61
62var
63 Str: String;
64 Val: String;
65
66procedure TTestMFunStr1.TestPiece1;
67begin
68 Val := Piece(Str,'^');
69 Check(Val = 'Piece1','Failed Piece not specified');
70end;
71
72procedure TTestMFunStr1.Setup;
73begin
74 Str := 'Piece1^Piece2^Piece3';
75end;
76
77procedure TTestMFunStr1.TestPiece2;
78begin
79 Val := Piece(Str,'^',2);
80 Check(Val = 'Piece2', 'Failed Piece specified as 2');
81end;
82
83procedure TTestMFunStr1.TestPiece3;
84begin
85 Val := Piece(Str,'^',3);
86 Check(Val = 'Piece3', 'Failed Piece specifed as 3');
87end;
88
89procedure TTestMFunStr1.TestPiece4;
90begin
91 Val := Piece(Str,'^',4);
92 Check(Val = '','Failed piece specifed as 4');
93end;
94
95procedure TTestMFunStr1.TestPiece5;
96begin
97 Val := Piece(Str,'^',1,2);
98 Check(Val = 'Piece1^Piece2','Failed Piece 1,2');
99end;
100
101procedure TTestMFunStr1.TestPiece6;
102begin
103 Val := Piece(Str,'^',2,3);
104 Check(Val = 'Piece2^Piece3','Failed Piece 2,3');
105end;
106
107procedure TTestMFunStr1.TestPiece7;
108begin
109 Val := Piece(Str,'^',2,4);
110 Check(Val = 'Piece2^Piece3', 'Failed on Piece 2,4');
111end;
112
113procedure TTestMFunStr1.TestPiece8;
114begin
115 Val := Piece(Str,'^',3,5);
116 Check(Val = 'Piece3','Failed on Piece 3,5');
117end;
118
119procedure TTestMFunStr1.TestPiece9;
120begin
121 Val := Piece(Str,'^',4,6);
122 Check(Val = '','Failed on Piece 4,6');
123end;
124
125procedure TTestMFunStr2.Setup;
126begin
127 Str := 'ABCDEFGHABCDE';
128end;
129
130procedure TTestMFunStr2.TestTran1;
131begin
132 Val := Translate(Str,'ABCDEFGH','abcdefgh');
133 Check(Val = 'abcdefghabcde','Failed upper to lower case');
134end;
135
136procedure TTestMFunStr2.TestTran2;
137begin
138 Val := Translate(Str,'ABCD','abcde');
139 Check(Val = 'abcdEFGHabcdE', 'Failed Partial');
140end;
141
142procedure TTestMFunStr2.TestTran3;
143begin
144 Val := Translate(Str,'ABCDEABC','abcdefgh');
145 Check(Val = 'abcdeFGHabcde', 'Failed repeat chars');
146end;
147
148procedure TTestMFunStr2.TestTran4;
149begin
150 Val := Translate(Str,'ABCDEFGH','abcdeabc');
151 Check(Val = 'abcdeabcabcde', 'Failed in assignment');
152end;
153
154{ // used with second method of registering tests
155function UnitTests: ITestSuite;
156var
157 ATestSuite: TTestSuite;
158begin
159 ATestSuite := TTestSuite.create('Some trivial tests');
160// add each test suite to be tested
161 ATestSuite.addSuite(TTestType.Suite);
162// ATestSuite.addSuite(TTestStringlist.Suite);
163 Result := ATestSuite;
164end;
165}
166
167
168{
169procedure TTestType.TestName1;
170begin
171// Check( Boolean true for success, String comment for failed test)
172 Check(1+1=2,'Comment on Failure')
173end;
174}
175
176initialization
177// one entry per testclass
178 TestFramework.RegisterTest('Test Piece',TTestMFunStr1.Suite);
179 TestFramework.RegisterTest('Test Translate',TTestMFunStr2.Suite);
180// or
181// TestFramework.RegisterTest('SimpleTest',UnitTests);
182end.
Note: See TracBrowser for help on using the repository browser.