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

Comparing:
ibx/trunk/fbintf/testsuite/Test1.pas (file contents), Revision 56 by tony, Mon Mar 6 10:20:02 2017 UTC vs.
ibx/branches/journaling/fbintf/testsuite/Test1.pas (file contents), Revision 362 by tony, Tue Dec 7 13:27:39 2021 UTC

# Line 1 | Line 1
1 + (*
2 + *  Firebird Interface (fbintf) Test suite. This program is used to
3 + *  test the Firebird Pascal Interface and provide a semi-automated
4 + *  pass/fail check for each test.
5 + *
6 + *  The contents of this file are subject to the Initial Developer's
7 + *  Public License Version 1.0 (the "License"); you may not use this
8 + *  file except in compliance with the License. You may obtain a copy
9 + *  of the License here:
10 + *
11 + *    http://www.firebirdsql.org/index.php?op=doc&id=idpl
12 + *
13 + *  Software distributed under the License is distributed on an "AS
14 + *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 + *  implied. See the License for the specific language governing rights
16 + *  and limitations under the License.
17 + *
18 + *  The Initial Developer of the Original Code is Tony Whyman.
19 + *
20 + *  The Original Code is (C) 2016 Tony Whyman, MWA Software
21 + *  (http://www.mwasoftware.co.uk).
22 + *
23 + *  All Rights Reserved.
24 + *
25 + *  Contributor(s): ______________________________________.
26 + *
27 + *)
28 +
29   unit Test1;
30   {$IFDEF MSWINDOWS}
31   {$DEFINE WINDOWS}
32   {$ENDIF}
33  
34 < {Create and Drop a Database}
34 > {Test 1: Create and Drop a Database}
35   {
36   This test first attempts to create a database without specifying any parameters
37   (should fail). It then goes on to create and drop a database, print out the
# Line 17 | Line 45 | unit Test1;
45   {$IFDEF FPC}
46   {$mode delphi}
47   {$codepage utf8}
48 + {$define HASREQEX}
49   {$ENDIF}
50  
51   interface
52  
53   uses
54 <  Classes, SysUtils, TestManager, IB;
54 >  Classes, SysUtils, TestApplication, FBTestApp, IB;
55  
56   type
57  
58    { TTest1 }
59  
60 <  TTest1 = class(TTestBase)
60 >  TTest1 = class(TFBTestBase)
61    private
62      procedure DoQuery(Attachment: IAttachment);
63 +    procedure GetFBVersion(Attachment: IAttachment);
64    public
65      function TestTitle: AnsiString; override;
66      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 54 | Line 84 | begin
84        while ResultSet.FetchNext do
85        begin
86          for i := 0 to ResultSet.getCount - 1 do
87 <          writeln(OutFile,ResultSet[i].Name,' = ',ResultSet[i].AsString);
87 >          writeln(OutFile,ResultSet[i].Name,' = ',Trim(ResultSet[i].AsString));
88        end;
89      finally
90        ResultSet.Close;
# Line 62 | Line 92 | begin
92      end;
93   end;
94  
95 + procedure TTest1.GetFBVersion(Attachment: IAttachment);
96 + var Version: TStrings;
97 +    i: integer;
98 + begin
99 +  Version := TStringList.Create;
100 +  try
101 +    Attachment.getFBVersion(Version);
102 +    for i := 0 to Version.Count - 1 do
103 +      writeln(OutFile,Version[i]);
104 +  finally
105 +    Version.Free;
106 +  end;
107 + end;
108 +
109   function TTest1.TestTitle: AnsiString;
110   begin
111    Result := 'Test 1: Create and Drop a Database';
# Line 71 | Line 115 | procedure TTest1.RunTest(CharSet: AnsiSt
115   var DPB: IDPB;
116      Attachment: IAttachment;
117      createSQL: AnsiString;
118 +    libpath: string;
119 +    FBLibrary: IFirebirdLibrary;
120   begin
121    writeln(OutFile,'Creating a Database with empty parameters');
122    Attachment := FirebirdAPI.CreateDatabase('',nil,false);
# Line 80 | Line 126 | begin
126      Attachment.DropDatabase;
127  
128    writeln(OutFile,'Creating a Database using an SQL Statement');
129 <  createSQL := Format('CREATE DATABASE ''%s'' USER ''%s'' PASSWORD ''%s'' DEFAULT CHARACTER SET %s',
129 >  createSQL := Format('create database ''%s'' USER ''%s'' PASSWORD ''%s'' DEFAULT CHARACTER SET %s',
130                        [Owner.GetNewDatabaseName, Owner.GetUserName, Owner.GetPassword, CharSet]);
131    Attachment := FirebirdAPI.CreateDatabase(createSQL,SQLDialect);
132    WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_db_SQL_Dialect]));
133 +  WriteAttachmentInfo(Attachment);
134 +  PrintDPB(Attachment.getDPB);
135 +  writeln(OutFile,'Firebird Server Version Info');
136 +  GetFBVersion(Attachment);
137 +  writeln(OutFile);
138 +
139 +  {$IFDEF HASREQEX}
140 +  {Demonstrate reconnect when database created with SQL Statement}
141 +  try
142 +    Attachment.Disconnect;
143 +    Attachment.Connect;
144 +  except on E:Exception do
145 +    writeln(OutFile,'Error reconnecting to Database: ',E.Message);
146 +  end;
147 +  {$ENDIF}
148  
149    writeln(OutFile,'Dropping Database');
150    if Attachment <> nil then
# Line 98 | Line 159 | begin
159  
160    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
161  
162 +  WriteAttachmentInfo(Attachment);
163 +
164    writeln(OutFile,'Dropping Database');
165    if Attachment <> nil then
166      Attachment.DropDatabase;
# Line 113 | Line 176 | begin
176      Exit;
177    end;
178    WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version]));
179 +  WriteAttachmentInfo(Attachment);
180  
181    {Querying Database}
182    DoQuery(Attachment);
183  
184    writeln(OutFile,'Dropping Database');
185    Attachment.DropDatabase;
186 +
187 +  libpath := GetEnvironmentVariable('TESTFIREBIRDLIBRARY');
188 +  if libpath <> '' then
189 +  begin
190 +    FBLibrary := LoadFBLibrary(libpath);
191 +
192 +    writeln(OutFile,'Creating a Database with a DPD using Firebird Library in ',libpath);
193 +    Attachment := FBLibrary.GetFirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
194 +    if Attachment = nil then
195 +    begin
196 +      writeln(OutFile,'Create Database Failed');
197 +      Exit;
198 +    end;
199 +    WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version]));
200 +    WriteAttachmentInfo(Attachment);
201 +
202 +    {Querying Database}
203 +    DoQuery(Attachment);
204 +
205 +    writeln(OutFile,'Dropping Database');
206 +    Attachment.DropDatabase;
207 +  end;
208   end;
209  
210  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines