-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_sets.pas
42 lines (33 loc) · 869 Bytes
/
test_sets.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
{$mode delphi}
{$i test_sets.def }{$h+}
implementation uses sets;
type
TStringSet = GSet<string>;
TCharSet = set of char;
const { these are built-in (set of char), tested with bits }
hexits = ['0'..'9','a'..'f'];
vowels = ['a','e','i','o','u'];
var { these use the custom implementation }
h, v : TStringSet;
function makeStringSet( chs : TCharSet ) : TStringSet;
var ch : char;
begin
result := TStringSet.Create;
for ch in chs do result.include( ch );
end;
function ToString( ss : TStringSet) : string;
var s : string;
begin
result := '';
for s in ss do result += s;
end;
procedure setup;
begin
h := makeStringSet(hexits);
v := makeStringSet(vowels);
end;
procedure test_iter;
begin
chk.equal( '0123456789abcdef', ToString(h));
end;
end.