-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegExp_Core_Test.pp
More file actions
39 lines (32 loc) · 916 Bytes
/
RegExp_Core_Test.pp
File metadata and controls
39 lines (32 loc) · 916 Bytes
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
program RegExp_Core_Test;
{$ASSERTIONS ON}
// {$DEFINE BENCHMARK}
uses
SysUtils, RegExp_Core;
var
Text: PWideChar;
SearchText: PWideChar;
Sequence: TCharGroupSequence;
StartTick: Int64;
I: LongWord;
begin
Text := 'Hello World';
// Scan for `Hello` in `Hello World`
SearchText := 'Hello';
Sequence := StringToSequence(SearchText);
Assert(ScanSequence(Text, 0, Sequence));
// Scan for `hello` in `Hello World`
SearchText := 'hello';
Sequence := StringToSequence(SearchText);
Assert(not ScanSequence(Text, 0, Sequence));
// Scan for `World` in `Hello World`
SearchText := 'World';
Sequence := StringToSequence(SearchText);
Assert(ScanSequence(Text, 0, Sequence));
{$IFDEF BENCHMARK}
StartTick := GetTickCount64();
for I := 1 to 1000000 do
Assert(ScanSequence(Text, 0, Sequence));
WriteLn(Format('Done in %d ms', [ GetTickCount64() - StartTick]));
{$ENDIF}
end.