Skip to content

Commit 810a5f6

Browse files
committed
Merge branch 'main' into Relations
2 parents b8b1c6a + c5a0f4d commit 810a5f6

6 files changed

Lines changed: 172 additions & 5 deletions

File tree

.github/workflows/make.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- ubuntu-latest
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@v6
3030
with:
3131
submodules: true
3232

core/dopf.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ destructor TdGConnection.Destroy;
707707
procedure TdGConnection.CheckBrokerClass;
708708
begin
709709
if not T1.InheritsFrom(TdConnectionBroker) then
710-
raise EdConnection.CreateFmt('Invalid broker class: "%s".', [T1.ClassName]);
710+
raise EdConnection.CreateFmt('Invalid broker class: "%s".', [ShortString(T1.ClassName)]);
711711
end;
712712

713713
procedure TdGConnection.CheckBroker;
@@ -719,7 +719,7 @@ procedure TdGConnection.CheckBroker;
719719
procedure TdGConnection.CheckLoggerClass;
720720
begin
721721
if not T2.InheritsFrom(TdLogger) then
722-
raise EdConnection.CreateFmt('Invalid logger class: "%s".', [T2.ClassName]);
722+
raise EdConnection.CreateFmt('Invalid logger class: "%s".', [ShortString(T2.ClassName)]);
723723
end;
724724

725725
function TdGConnection.GetConnected: Boolean;
@@ -1297,7 +1297,7 @@ procedure TdGQuery.SetParams(AEntity: TObject);
12971297
procedure TdGQuery.CheckBrokerClass;
12981298
begin
12991299
if not T1.InheritsFrom(TdQueryBroker) then
1300-
raise EdQuery.CreateFmt('Invalid broker class: "%s".', [T1.ClassName]);
1300+
raise EdQuery.CreateFmt('Invalid broker class: "%s".', [ShortString(T1.ClassName)]);
13011301
end;
13021302

13031303
procedure TdGQuery.CheckBroker;

tests/console.lpr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
{$mode objfpc}{$H+}
44

55
uses
6-
Classes, consoletestrunner, test_insertbuilder
6+
Classes, consoletestrunner,
7+
test_insertbuilder, test_dclasses, test_dopf, test_dutils
78
;
89
type
910

tests/test_dclasses.pas

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
unit test_dclasses;
2+
3+
{$mode objfpc}{$H+}
4+
5+
interface
6+
7+
uses
8+
fpcunit, testregistry, dclasses, Classes;
9+
10+
type
11+
TTestDClasses = class(TTestCase)
12+
published
13+
procedure TestInheritances;
14+
end;
15+
16+
implementation
17+
18+
uses
19+
SysUtils
20+
;
21+
22+
procedure TTestDClasses.TestInheritances;
23+
begin
24+
AssertTrue(EdException.InheritsFrom(Exception));
25+
AssertTrue(TdObject.InheritsFrom(TObject));
26+
AssertTrue(TdComponent.InheritsFrom(TComponent));
27+
end;
28+
29+
initialization
30+
RegisterTest(TTestDClasses);
31+
end.

tests/test_dopf.pas

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
unit test_dopf;
2+
3+
{$mode objfpc}{$H+}
4+
5+
interface
6+
7+
uses
8+
fpcunit, testregistry, dopf, Classes;
9+
10+
type
11+
TTestDOpf = class(TTestCase)
12+
published
13+
procedure TestConnectionBrokerConnect;
14+
procedure TestGConnectionCreate;
15+
end;
16+
17+
implementation
18+
19+
type
20+
TMyConnection = class(specialize TdGConnection<TdConnectionBroker, TdLogger>);
21+
22+
procedure TTestDOpf.TestConnectionBrokerConnect;
23+
var
24+
B: TdConnectionBroker;
25+
begin
26+
B := TdConnectionBroker.Create;
27+
try
28+
try
29+
B.Connect;
30+
Fail('Expected exception');
31+
except
32+
on E: EdNotImplemented do ;
33+
end;
34+
finally
35+
B.Free;
36+
end;
37+
end;
38+
39+
procedure TTestDOpf.TestGConnectionCreate;
40+
var
41+
C: TMyConnection;
42+
begin
43+
C := TMyConnection.Create(nil);
44+
try
45+
AssertTrue(Assigned(C.Broker));
46+
AssertTrue(Assigned(C.Logger));
47+
finally
48+
C.Free;
49+
end;
50+
end;
51+
52+
initialization
53+
RegisterTest(TTestDOpf);
54+
end.

tests/test_dutils.pas

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
unit test_dutils;
2+
3+
{$mode objfpc}{$H+}
4+
5+
interface
6+
7+
uses
8+
fpcunit, testregistry, dutils;
9+
10+
type
11+
TTestDUtils = class(TTestCase)
12+
published
13+
procedure TestParameterizeSQLNilParams;
14+
procedure TestGetFieldsNilObject;
15+
procedure TestSetFieldsNilObject;
16+
procedure TestGetParamsNilObject;
17+
procedure TestSetParamsNilObject;
18+
end;
19+
20+
implementation
21+
22+
uses
23+
dClasses
24+
;
25+
26+
procedure TTestDUtils.TestParameterizeSQLNilParams;
27+
var
28+
S: string;
29+
begin
30+
S := 'select * from t where id=:id';
31+
try
32+
dParameterizeSQL(S, nil);
33+
Fail('Expected exception');
34+
except
35+
on E: EdException do ;
36+
end;
37+
end;
38+
39+
procedure TTestDUtils.TestGetFieldsNilObject;
40+
begin
41+
try
42+
dGetFields(nil, nil);
43+
Fail('Expected exception');
44+
except
45+
on E: EdException do ;
46+
end;
47+
end;
48+
49+
procedure TTestDUtils.TestSetFieldsNilObject;
50+
begin
51+
try
52+
dSetFields(nil, nil);
53+
Fail('Expected exception');
54+
except
55+
on E: EdException do ;
56+
end;
57+
end;
58+
59+
procedure TTestDUtils.TestGetParamsNilObject;
60+
begin
61+
try
62+
dGetParams(nil, nil);
63+
Fail('Expected exception');
64+
except
65+
on E: EdException do ;
66+
end;
67+
end;
68+
69+
procedure TTestDUtils.TestSetParamsNilObject;
70+
begin
71+
try
72+
dSetParams(nil, nil);
73+
Fail('Expected exception');
74+
except
75+
on E: EdException do ;
76+
end;
77+
end;
78+
79+
initialization
80+
RegisterTest(TTestDUtils);
81+
end.

0 commit comments

Comments
 (0)