mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
* Added two fcl-db tests to the general testsuite
git-svn-id: trunk@12216 -
This commit is contained in:
parent
2425eb4721
commit
9f2e076cb3
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -7586,6 +7586,12 @@ tests/test/opt/treg3.pp svneol=native#text/plain
|
||||
tests/test/opt/treg4.pp svneol=native#text/plain
|
||||
tests/test/opt/tretopt.pp svneol=native#text/plain
|
||||
tests/test/opt/tspace.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/assertions.pas svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/database.ini svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/dbftoolsunit.pas svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/tdb1.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/tdb2.pp svneol=native#text/plain
|
||||
tests/test/packages/fcl-db/toolsunit.pas svneol=native#text/plain
|
||||
tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
|
||||
tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
|
||||
tests/test/packages/webtbs/tw10045.pp svneol=native#text/plain
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/09/28]
|
||||
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/11/23]
|
||||
#
|
||||
default: allexectests
|
||||
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
|
||||
@ -1443,7 +1443,7 @@ ifndef LOG
|
||||
export LOG:=$(TEST_OUTPUTDIR)/log
|
||||
endif
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db
|
||||
ifdef QUICKTEST
|
||||
export QUICKTEST
|
||||
else
|
||||
|
@ -120,7 +120,7 @@ endif
|
||||
|
||||
# Subdirs available in the test subdir
|
||||
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib
|
||||
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process packages/zlib packages/fcl-db
|
||||
|
||||
ifdef QUICKTEST
|
||||
export QUICKTEST
|
||||
|
32
tests/test/packages/fcl-db/assertions.pas
Normal file
32
tests/test/packages/fcl-db/assertions.pas
Normal file
@ -0,0 +1,32 @@
|
||||
unit Assertions;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
procedure AssertTrue(v1 : boolean);
|
||||
procedure AssertEquals(v1,v2 : string); overload;
|
||||
procedure AssertEquals(v1,v2 : integer); overload;
|
||||
|
||||
implementation
|
||||
|
||||
procedure AssertTrue(v1: boolean);
|
||||
begin
|
||||
if not v1 then halt(1);
|
||||
end;
|
||||
|
||||
procedure AssertEquals(v1, v2: string);
|
||||
begin
|
||||
AssertTrue(v1=v2);
|
||||
end;
|
||||
|
||||
procedure AssertEquals(v1, v2: integer);
|
||||
begin
|
||||
AssertTrue(v1=v2);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
90
tests/test/packages/fcl-db/database.ini
Normal file
90
tests/test/packages/fcl-db/database.ini
Normal file
@ -0,0 +1,90 @@
|
||||
; This file contains several sections, one for each database-type. Select here
|
||||
; which section has to be used currently.
|
||||
[Database]
|
||||
type=dbf
|
||||
|
||||
; These sections are for the several SQLDB-types of databases:
|
||||
[postgresql]
|
||||
|
||||
; The connector specifies the DB-component that has to be used. The 'sql'
|
||||
; connector tests the SQLDB components
|
||||
connector=sql
|
||||
|
||||
; Here you can give some parameters, which are specific for each connector. The
|
||||
; SQL connector uses this parameter to specify the connection that should be
|
||||
; used;
|
||||
connectorparams=postgresql
|
||||
|
||||
; The name of the database. The database could be empty. You only need read and
|
||||
; write rights.
|
||||
name=testdb
|
||||
|
||||
; user to log in with
|
||||
user=
|
||||
|
||||
; password to log in with
|
||||
password=
|
||||
|
||||
; hostname of the database-server
|
||||
hostname=127.0.0.1
|
||||
|
||||
[mysql40]
|
||||
connector=sql
|
||||
connectorparams=mysql40
|
||||
name=testdb
|
||||
user=root
|
||||
password=
|
||||
hostname=127.0.0.1
|
||||
|
||||
[mysql41]
|
||||
connector=sql
|
||||
connectorparams=mysql41
|
||||
name=testdb
|
||||
user=root
|
||||
password=
|
||||
hostname=127.0.0.1
|
||||
|
||||
[mysql50]
|
||||
connector=sql
|
||||
connectorparams=mysql50
|
||||
name=testdb
|
||||
user=root
|
||||
password=
|
||||
hostname=127.0.0.1
|
||||
|
||||
[oracle]
|
||||
connector=sql
|
||||
connectorparams=oracle
|
||||
name=xe
|
||||
user=system
|
||||
password=
|
||||
hostname=127.0.0.1
|
||||
|
||||
[interbase]
|
||||
connector=sql
|
||||
connectorparams=interbase
|
||||
name=/opt/firebird/data/testdb.fdb
|
||||
user=sysdba
|
||||
password=
|
||||
hostname=localhost
|
||||
|
||||
[odbc]
|
||||
connector=sql
|
||||
connectorparams=odbc
|
||||
name=testdb
|
||||
user=root
|
||||
password=
|
||||
hostname=127.0.0.1
|
||||
|
||||
|
||||
; This section is for a connector for TDbf:
|
||||
[dbf]
|
||||
connector=dbf
|
||||
|
||||
; Give here the path where the *.dbf file can be generated
|
||||
name=.
|
||||
|
||||
; This section is for a connector for MemDS:
|
||||
[memds]
|
||||
connector=memds
|
||||
|
1
tests/test/packages/fcl-db/dbftoolsunit.pas
Normal file
1
tests/test/packages/fcl-db/dbftoolsunit.pas
Normal file
@ -0,0 +1 @@
|
||||
{$i ../../../../packages/fcl-db/tests/dbftoolsunit.pas}
|
44
tests/test/packages/fcl-db/tdb1.pp
Normal file
44
tests/test/packages/fcl-db/tdb1.pp
Normal file
@ -0,0 +1,44 @@
|
||||
program TTestDBBasics_TestGetFieldValues;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
Assertions,
|
||||
ToolsUnit,
|
||||
dbftoolsunit,
|
||||
db;
|
||||
|
||||
var AVar : Variant;
|
||||
PassException : boolean;
|
||||
|
||||
begin
|
||||
InitialiseDBConnector;
|
||||
with DBConnector.GetNDataset(true,14) do
|
||||
begin
|
||||
open;
|
||||
AVar:=FieldValues['id'];
|
||||
AssertEquals(AVar,1);
|
||||
|
||||
AVar:=FieldValues['name'];
|
||||
AssertEquals(AVar,'TestName1');
|
||||
|
||||
AVar:=FieldValues['id;name'];
|
||||
AssertEquals(AVar[0],1);
|
||||
AssertEquals(AVar[1],'TestName1');
|
||||
|
||||
AVar:=FieldValues['name;id;'];
|
||||
AssertEquals(AVar[1],1);
|
||||
AssertEquals(AVar[0],'TestName1');
|
||||
|
||||
PassException:=false;
|
||||
try
|
||||
AVar:=FieldValues['name;id;fake'];
|
||||
except
|
||||
on E: EDatabaseError do PassException := True;
|
||||
end;
|
||||
AssertTrue(PassException);
|
||||
|
||||
end;
|
||||
end.
|
||||
|
47
tests/test/packages/fcl-db/tdb2.pp
Normal file
47
tests/test/packages/fcl-db/tdb2.pp
Normal file
@ -0,0 +1,47 @@
|
||||
program TTestDBBasics_TestSetFieldValues;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
Assertions,
|
||||
ToolsUnit,
|
||||
dbftoolsunit,
|
||||
variants,
|
||||
db;
|
||||
|
||||
var PassException : boolean;
|
||||
|
||||
begin
|
||||
InitialiseDBConnector;
|
||||
with DBConnector.GetNDataset(true,11) do
|
||||
begin
|
||||
open;
|
||||
first;
|
||||
edit;
|
||||
FieldValues['id']:=5;
|
||||
post;
|
||||
AssertEquals('TestName1',FieldByName('name').AsString);
|
||||
AssertEquals(5,FieldByName('id').AsInteger);
|
||||
edit;
|
||||
FieldValues['name']:='FieldValuesTestName';
|
||||
post;
|
||||
AssertEquals('FieldValuesTestName',FieldByName('name').AsString);
|
||||
AssertEquals(5,FieldByName('id').AsInteger);
|
||||
edit;
|
||||
FieldValues['id;name']:= VarArrayOf([243,'ValuesTestName']);
|
||||
post;
|
||||
AssertEquals('ValuesTestName',FieldByName('name').AsString);
|
||||
AssertEquals(243,FieldByName('id').AsInteger);
|
||||
|
||||
PassException:=false;
|
||||
try
|
||||
edit;
|
||||
FieldValues['id;name;fake']:= VarArrayOf([243,'ValuesTestName',4]);
|
||||
except
|
||||
on E: EDatabaseError do PassException := True;
|
||||
end;
|
||||
post;
|
||||
AssertTrue(PassException);
|
||||
end;
|
||||
end.
|
1
tests/test/packages/fcl-db/toolsunit.pas
Normal file
1
tests/test/packages/fcl-db/toolsunit.pas
Normal file
@ -0,0 +1 @@
|
||||
{$i ../../../../packages/fcl-db/tests/toolsunit.pas}
|
Loading…
Reference in New Issue
Block a user