program test;
{$APPTYPE CONSOLE}
uses
fastwild;
const
TrueTests: array[0..18, 0..1] of string = (
('', ''),
('a', 'a'),
('?', 'a'),
('??', 'ab'),
('*', ''),
('*', 'a'),
('*', 'aa'),
('*???', 'abc'),
('*???', 'abcd'),
('*test?*', 'tester'),
('*.*', 'fastwild.pas'),
('[a-z]', 'a'),
('[+a-z]', 'hallo'),
('[*a-z]', ''),
('[!abc]', 'd'),
('[a-]', '-'),
('[z-a]', '-'),
('[!-c]', 'b'),
('*a*b*', 'kebab')
);
FalseTests: array[0..4, 0..1] of string = (
('a', 'b'),
('', 'a'),
('*???', 'ab'),
('?', ''),
('*a*b*', 'erbanlage')
);
var
i: integer;
f: TWildcardFunction;
begin
WriteLn(' pattern string exp.res. result');
WriteLn('==============================================================');
for i := low(TrueTests) to high(TrueTests) do
begin
f := CompileWildcardFunction(TrueTests[i, 0]);
try
WriteLn(TrueTests[i, 0]:16, TrueTests[i, 1]:21, 'TRUE':13, f(PChar(TrueTests[i, 1])):10);
finally
FreeWildcardFunction(f);
end;
end;
for i := low(FalseTests) to high(FalseTests) do
begin
f := CompileWildcardFunction(FalseTests[i, 0]);
try
WriteLn(FalseTests[i, 0]:16, FalseTests[i, 1]:21, 'FALSE':13, f(PChar(FalseTests[i, 1])):10);
finally
FreeWildcardFunction(f);
end;
end;
ReadLn;
end.