Changeset 94 for trunk/UTest.pas
- Timestamp:
- Feb 3, 2022, 10:53:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTest.pas
r91 r94 6 6 7 7 uses 8 Classes, SysUtils, fgl ;8 Classes, SysUtils, fgl, UContact; 9 9 10 10 type … … 19 19 Log: string; 20 20 procedure Run; virtual; 21 procedure Evaluate(Passed: Boolean); 22 procedure Pass; 23 procedure Fail; 21 24 end; 22 25 … … 35 38 Output: string; 36 39 procedure Run; override; 37 procedure Evaluate(Passed: Boolean); 40 end; 41 42 { TTestCaseCheckProperty } 43 44 TTestCaseCheckProperty = class(TTestCase) 45 Input: string; 46 ContactIndex: Integer; 47 Index: TContactFieldIndex; 48 Value: string; 49 procedure Run; override; 38 50 end; 39 51 … … 44 56 implementation 45 57 46 uses 47 UContact; 58 { TTestCaseCheckProperty } 59 60 procedure TTestCaseCheckProperty.Run; 61 var 62 Lines: TStringList; 63 PropertyValue: string; 64 begin 65 Lines := TStringList.Create; 66 try 67 with TContactsFile.Create do 68 try 69 Lines.Text := Input; 70 LoadFromStrings(Lines); 71 if ContactIndex < Contacts.Count then begin 72 PropertyValue := Contacts[ContactIndex].Fields[Index]; 73 Evaluate(PropertyValue = Value); 74 end else Fail; 75 Log := 'Expected:' + LineEnding + 76 '"' + Value + '"' + LineEnding + LineEnding + 77 'Output:' + LineEnding + 78 '"' + PropertyValue + '"'; 79 finally 80 Free; 81 end; 82 finally 83 Lines.Free; 84 end; 85 end; 48 86 49 87 { TTestCaseLoadSave } … … 62 100 SaveToStrings(Lines); 63 101 Evaluate(Lines.Text = Output); 64 if Result <> trPassed then begin 65 Log := 'Expected:' + LineEnding + 66 '"' + Output + '"' + LineEnding + LineEnding + 67 'Output:' + LineEnding + 68 '"' + Lines.Text + '"'; 69 end; 102 Log := 'Expected:' + LineEnding + 103 '"' + Output + '"' + LineEnding + LineEnding + 104 'Output:' + LineEnding + 105 '"' + Lines.Text + '"'; 70 106 finally 71 107 Free; … … 76 112 end; 77 113 78 procedure TTestCaseLoadSave.Evaluate(Passed: Boolean); 114 { TTestCase } 115 116 procedure TTestCase.Run; 117 begin 118 end; 119 120 procedure TTestCase.Evaluate(Passed: Boolean); 79 121 begin 80 122 if Passed then Result := trPassed … … 82 124 end; 83 125 84 { TTestCase } 126 procedure TTestCase.Pass; 127 begin 128 Result := trPassed; 129 end; 85 130 86 procedure TTestCase. Run;131 procedure TTestCase.Fail; 87 132 begin 88 133 Result := trFailed; 89 134 end; 90 135
Note:
See TracChangeset
for help on using the changeset viewer.