-
Notifications
You must be signed in to change notification settings - Fork 0
/
idtest.pas
71 lines (56 loc) · 1.1 KB
/
idtest.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
unit IdTest;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry, Id;
type
TIdTest= class(TTestCase)
published
procedure EqualsOk;
procedure CreateOk;
end;
implementation
procedure TIdTest.EqualsOK;
var
I1, I2, I3 : TId;
begin
I1 := TId.CreateFromString('test');
I2 := TId.CreateFromString('test');
I3 := TId.CreateFromString('dupa');
AssertTrue(i1.Equals(I2));
AssertTrue(i2.Equals(I1));
AssertFalse(i3.Equals(I1));
AssertFalse(i3.Equals(I2));
i1.Free;
i2.Free;
i3.Free;
end;
procedure TIdTest.CreateOk;
type
TIdArray = Array [1..1000] of TId;
var
Ids : TIdArray;
i,j : Integer;
test : Boolean;
begin
for i := 1 to 1000 do
begin
Ids[i] := TId.Create;
end;
for i := 1 to 1000 do
for j := 1 to 1000 do
begin
test := Ids[i].Equals(Ids[j]);
if i <> j then
AssertFalse(test)
else
AssertTrue(test);
end;
for i := 1 to 1000 do
begin
Ids[i].Free;
end;
end;
initialization
RegisterTest(TIdTest);
end.