ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/testsuite/Test21.pas
(Generate patch)

Comparing ibx/trunk/testsuite/Test21.pas (file contents):
Revision 344 by tony, Thu Feb 25 12:14:35 2021 UTC vs.
Revision 345 by tony, Mon Aug 23 14:22:29 2021 UTC

# Line 37 | Line 37 | unit Test21;
37   interface
38  
39   uses
40 <  Classes, SysUtils,   TestApplication, IBXTestBase, IB, IBSQL, MD5;
40 >  Classes, SysUtils,   TestApplication, IBXTestBase, IB, IBSQL;
41  
42   const
43    aTestID    = '21';
# Line 50 | Line 50 | type
50    TTest21 = class(TIBXTestBase)
51    private
52      FIBSQL: TIBSQL;
53 <    function StuffDatabase: TMDDigest;
54 <    function ReadDatabase: TMDDigest;
53 >    function StuffDatabase: TMsgHash;
54 >    function ReadDatabase: TMsgHash;
55    protected
56      procedure CreateObjects(Application: TTestApplication); override;
57      function GetTestID: AnsiString; override;
# Line 72 | Line 72 | const
72  
73   { TTest21 }
74  
75 < function TTest21.StuffDatabase: TMDDigest;
75 > function TTest21.StuffDatabase: TMsgHash;
76   var i: integer;
77      HashString: AnsiString;
78    MD5Context: TMDContext;
78      Started: TDateTime;
79   begin
80    Started := Now;
81 +  Result := TMsgHash.CreateMsgHash;
82    writeln(Outfile,'Loading data into database table. Started at ',DateTimeToStr(Started));
83  MDInit(MD5Context,MD_VERSION_5);
83    IBTransaction.Active := true;
84    for i := 1 to RecordCount do
85    with FIBSQL do
# Line 90 | Line 89 | begin
89      Params[2].AsDateTime := Now;
90      HashString := Params[0].Asstring + Params[1].AsString + DateTimeToStr(Params[2].AsDateTime);
91      ExecQuery;
92 <    MDUpdate(MD5Context,PAnsiChar(HashString)^,Length(HashString));
92 >    Result.AddText(HashString);
93    end;
94    IBTransaction.Commit;
95 <  MDFinal(MD5Context,Result);
95 >  Result.Finalise;
96    writeln(OutFile, 'Data load completed at ',DateTimeToStr(Now), ' Elapsed Time = ',
97      (MilliSecondsBetween(Now,Started)),' ms, ',RecordCount,' records loaded');
98 <  writeln(Outfile,' MD5 checksum = ',MD5Print(Result));
98 >  writeln(Outfile,' Message Hash = ',Result.Digest);
99   end;
100  
101 < function TTest21.ReadDatabase: TMDDigest;
102 < var MD5Context: TMDContext;
104 <    Started: TDateTime;
101 > function TTest21.ReadDatabase: TMsgHash;
102 > var Started: TDateTime;
103      HashString: AnsiString;
104      Count: integer;
105   begin
106 <  MDInit(MD5Context,MD_VERSION_5);
106 >  Result := TMsgHash.CreateMsgHash;
107    IBTransaction.Active := true;
108    Started := Now;
109    Count := 0;
# Line 117 | Line 115 | begin
115      begin
116        Inc(Count);
117        HashString := Fields[0].AsString + Fields[1].AsString + DateTimeToStr(Fields[2].AsDateTime);
118 <      MDUpdate(MD5Context,PAnsiChar(HashString)^,Length(HashString));
118 >      Result.AddText(HashString);
119        Next;
120      end;
121    end;
122    writeln(OutFile, 'Read Dataset completed at ',DateTimeToStr(Now), ' Elapsed Time = ',
123      (MilliSecondsBetween(Now,Started)), ' ms, ',Count,' records read');
124 <  MDFinal(MD5Context,Result);
125 <  writeln(Outfile,' MD5 checksum = ',MD5Print(Result));
124 >  Result.Finalise;
125 >  writeln(Outfile,' Message Hash = ',Result.Digest);
126   end;
127  
128   procedure TTest21.CreateObjects(Application: TTestApplication);
# Line 159 | Line 157 | begin
157   end;
158  
159   procedure TTest21.RunTest(CharSet: AnsiString; SQLDialect: integer);
160 < var Digest: TMD5Digest;
160 > var InHash,OutHash: TMsgHash;
161   begin
162    IBDatabase.CreateDatabase;
163    try
164 <    Digest := StuffDatabase;  {This creates a database holding a large 100,000 record table}
165 <    if MD5Match(Digest,ReadDatabase) then
166 <      writeln(Outfile,'Test Completed successfully')
167 <    else
168 <      writeln(Outfile,'Test failed. MD5 checksum error');
169 <    writeln(Outfile,DateTimeToStr(Now),' Test ',aTestID,' passes as long as the MD5 sums are identical');
164 >    InHash := StuffDatabase;  {This creates a database holding a large 100,000 record table}
165 >    try
166 >      OutHash := ReadDatabase;
167 >      try
168 >        if InHash.SameHash(OutHash) then
169 >          writeln(Outfile,'Test Completed successfully')
170 >        else
171 >          writeln(Outfile,'Test failed. Message checksum error');
172 >        writeln(Outfile,DateTimeToStr(Now),' Test ',aTestID,' passes as long as the checksums are identical');
173 >      finally
174 >        OutHash.Free;
175 >      end;
176 >    finally
177 >      Inhash.Free;
178 >    end;
179    finally
180      IBDatabase.DropDatabase;
181    end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines