Menu

[r2995]: / branches / new-backend / Tests / Src / DUnit / TestDBUSnippetKindGroup.pas  Maximize  Restore  History

Download this file

140 lines (114 with data), 3.6 kB

  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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
Delphi DUnit Test Case for the DB.USnippetKindGroup Unit
--------------------------------------------------------
$Rev$
$Date$
}
unit TestDBUSnippetKindGroup;
interface
uses
TestFramework, DB.UBaseGroup, DB.UConsts, DB.USnippetKindGroup;
type
// Test methods for record TDBSnippetKindGroupKey
TestTDBSnippetKindGroupKey = class(TTestCase)
published
procedure TestCreate;
procedure TestEqualityOperators;
procedure TestImplicitTSnippetKindCast;
end;
// Test methods for class TDBSnippetKindGroup
TestTDBSnippetKindGroup = class(TTestCase)
strict private
function CreateObject(const Kind: TDBSnippetKind): TDBSnippetKindGroup;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestCreate;
end;
implementation
uses
UTestHelpers;
{ TestTDBSnippetKindGroupKey }
procedure TestTDBSnippetKindGroupKey.TestCreate;
var
K: TDBSnippetKindGroupKey;
begin
K := TDBSnippetKindGroupKey.Create(skRoutine);
Check(K.Kind = skRoutine);
K := TDBSnippetKindGroupKey.Create(skConstant);
Check(K.Kind = skConstant);
K := TDBSnippetKindGroupKey.Create(skTypeDef);
Check(K.Kind = skTypeDef);
K := TDBSnippetKindGroupKey.Create(skFreeform);
Check(K.Kind = skFreeform);
end;
procedure TestTDBSnippetKindGroupKey.TestEqualityOperators;
var
K0, K2, K2a, K3: TDBSnippetKindGroupKey;
begin
K0 := TDBSnippetKindGroupKey.Create(skRoutine);
K2 := TDBSnippetKindGroupKey.Create(skTypeDef);
K2a := TDBSnippetKindGroupKey.Create(skTypeDef);
K3 := TDBSnippetKindGroupKey.Create(skFreeform);
CheckFalse(K0 = K3);
CheckTrue(K0 <> K3);
CheckFalse(K3 = K2);
CheckTrue(K3 <> K2);
CheckTrue(K2 = K2a);
CheckFalse(K2 <> K2a);
end;
procedure TestTDBSnippetKindGroupKey.TestImplicitTSnippetKindCast;
var
Key: TDBSnippetKindGroupKey;
Kind: TDBSnippetKind;
begin
Key := TDBSnippetKindGroupKey.Create(skConstant);
Kind := Key;
Check(Kind = skConstant);
end;
{ TestTDBSnippetKindGroup }
function TestTDBSnippetKindGroup.CreateObject(const Kind: TDBSnippetKind):
TDBSnippetKindGroup;
begin
Result := TDBSnippetKindGroup.Create(Kind);
Result.FreeController := TAlwaysFreeController.Create;
end;
procedure TestTDBSnippetKindGroup.SetUp;
begin
end;
procedure TestTDBSnippetKindGroup.TearDown;
begin
end;
procedure TestTDBSnippetKindGroup.TestCreate;
var
O0, O1, O2, O3: TDBSnippetKindGroup;
resourcestring
sRoutine = 'Routine';
sConstant = 'Constant';
sType = 'Type Definition';
sFreeform = 'Freeform';
begin
O0 := nil; O1 := nil; O2 := nil; O3 := nil;
try
O0 := CreateObject(skRoutine);
O1 := CreateObject(skConstant);
O2 := CreateObject(skTypeDef);
O3 := CreateObject(skFreeform);
Check(O0.Key.Kind = skRoutine, 'Expected O0.Key.Kind = skRoutine');
Check(O1.Key.Kind = skConstant, 'Expected O1.Key.Kind = skConstant');
Check(O2.Key.Kind = skTypeDef, 'Expected O2.Key.Kind = skType');
Check(O3.Key.Kind = skFreeform, 'Expected O3.Key.Kind = skFreeform');
Check(O0.DisplayName = sRoutine, 'Expected O0.DisplayName = ' + sRoutine);
Check(O1.DisplayName = sConstant, 'Expected O0.DisplayName = ' + sConstant);
Check(O2.DisplayName = sType, 'Expected O0.DisplayName = ' + sType);
Check(O3.DisplayName = sFreeform, 'Expected O0.DisplayName = ' + sFreeform);
finally
O0.Free; O1.Free; O2.Free; O3.Free;
end;
end;
initialization
// Register any test cases with the test runner
RegisterTest(TestTDBSnippetKindGroupKey.Suite);
RegisterTest(TestTDBSnippetKindGroup.Suite);
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.