fcl-db: tests: Adjust tests to take into account connection charset and field codepage when testing Size and DataSize

git-svn-id: trunk@39003 -
This commit is contained in:
lacak 2018-05-16 11:30:37 +00:00
parent 7b7d9b1cde
commit 1edf2d3cd0
4 changed files with 33 additions and 41 deletions

View File

@ -35,6 +35,9 @@ password=masterkey
; of the database server
hostname=localhost
; connection character set
charset=
; SQL command log file (for sqldb databases)
; will be appended to each run
; uncomment to use
@ -57,42 +60,7 @@ name=fbembedtest.fdb
user=sysdba
password=masterkey
hostname=
[mysql40]
; MySQL 4.0 database:
connector=sql
connectorparams=mysql40
name=testdb
user=root
password=
hostname=127.0.0.1
[mysql41]
; MySQL 4.1 database:
connector=sql
connectorparams=mysql41
name=testdb
user=root
password=
hostname=127.0.0.1
[mysql50]
; MySQL 5.0 database:
connector=sql
connectorparams=mysql50
name=testdb
user=root
password=
hostname=127.0.0.1
[mysql51]
; MySQL 5.1 database:
connector=sql
connectorparams=mysql51
name=testdb
user=root
password=
hostname=127.0.0.1
charset=utf8
[mysql55]
; MySQL 5.5 database:
@ -112,6 +80,16 @@ user=root
password=
hostname=127.0.0.1
[mysql57]
; MySQL 5.7 database:
connector=sql
connectorparams=mysql57
name=testdb
user=root
password=
hostname=127.0.0.1
charset=utf8mb4
[mssql]
; MS SQL Server database:
connector=sql
@ -161,6 +139,7 @@ hostname=127.0.0.1
connector=sql
connectorparams=sqlite3
name=test.db
charset=utf-8
[sybase]
; Sybase ASE database

View File

@ -2684,7 +2684,7 @@ var i : byte;
Fld : TField;
begin
TestFieldDefinition(ftString,11,ds,Fld);
TestFieldDefinition(ftString, 10*DBConnector.CharSize+1, ds, Fld);
for i := 0 to testValuesCount-1 do
begin
@ -2872,7 +2872,7 @@ var i : byte;
Fld : TField;
begin
TestFieldDefinition(ftFixedChar,11,ds,Fld);
TestFieldDefinition(ftFixedChar, 10*DBConnector.CharSize+1, ds, Fld);
for i := 0 to testValuesCount-1 do
begin

View File

@ -438,7 +438,7 @@ var
begin
CreateTableWithFieldType(ftString,'VARCHAR(10)');
TestFieldDeclaration(ftString,11);
TestFieldDeclaration(ftString,10*DBConnector.CharSize+1);
for i := 0 to testValuesCount-1 do
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''' + testValues[i] + ''')');
@ -935,7 +935,7 @@ var
begin
CreateTableWithFieldType(ftString,'VARCHAR(9000)');
TestFieldDeclaration(ftString,9001);
TestFieldDeclaration(ftString,9000*DBConnector.CharSize+1);
setlength(s,9000);
for i := 1 to 9000 do

View File

@ -26,6 +26,7 @@ type
FLogTimeFormat: TFormatSettings; //for error logging only
FFormatSettings: TFormatSettings;
FChangedFieldDataset : boolean;
function GetCharSize: integer;
protected
FChangedDatasets : array[0..MaxDataSet] of boolean;
FUsedDatasets : TFPList;
@ -78,6 +79,7 @@ type
procedure StopTest(TestName: string);
property TestUniDirectional: boolean read GetTestUniDirectional write SetTestUniDirectional;
property FormatSettings: TFormatSettings read FFormatSettings;
property CharSize: integer read GetCharSize;
end;
{ TTestDataLink }
@ -241,6 +243,7 @@ function TimeStringToDateTime(d: String): TDateTime;
function StringToByteArray(const s: ansistring): Variant;
function StringToBytes(const s: ansistring): TBytes;
implementation
uses
@ -292,7 +295,7 @@ begin
raise exception.create('Connector does not support tests for unidirectional datasets');
end;
procedure TDBConnector.DataEvent(dataset : tdataset);
procedure TDBConnector.DataEvent(dataset: TDataset);
begin
DataEvents := DataEvents + 'DataEvent' + ';';
end;
@ -382,6 +385,16 @@ begin
end;
end;
function TDBConnector.GetCharSize: integer;
begin
case LowerCase(dbcharset) of
'utf8','utf-8','utf8mb4':
Result := 4;
else
Result := 1;
end;
end;
{ TTestDataLink }