summaryrefslogtreecommitdiff
path: root/tests/test/units/strutils/tboyer.pp
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-25 12:57:35 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-25 12:57:35 +0000
commit62a1b530781fb75b935bb40c2a2a10b7b0944d62 (patch)
treec1220a62e200224d81a44279592a151a8b400477 /tests/test/units/strutils/tboyer.pp
parentd0a4cf5fe4973cfc598876e8ac98fcbf4f04e7d9 (diff)
downloadfpc-62a1b530781fb75b935bb40c2a2a10b7b0944d62.tar.gz
--- Merging r48752 into '.':
U packages/rtl-objpas/src/inc/strutils.pp A tests/test/units/strutils/tboyer.pp --- Recording mergeinfo for merge of r48752 into '.': U . # revisions: 48752 r48752 | florian | 2021-02-21 14:54:25 +0100 (Sun, 21 Feb 2021) | 2 lines Changed paths: M /trunk/packages/rtl-objpas/src/inc/strutils.pp A /trunk/tests/test/units/strutils/tboyer.pp * fix by avk for issue #38513 + test git-svn-id: https://svn.freepascal.org/svn/fpc/branches/fixes_3_2@49050 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/test/units/strutils/tboyer.pp')
-rw-r--r--tests/test/units/strutils/tboyer.pp79
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/test/units/strutils/tboyer.pp b/tests/test/units/strutils/tboyer.pp
new file mode 100644
index 0000000000..7eb6fda835
--- /dev/null
+++ b/tests/test/units/strutils/tboyer.pp
@@ -0,0 +1,79 @@
+{$mode objfpc}
+
+uses
+ StrUtils;
+const
+ result1 : array of SizeInt = (1, 4, 7, 10, 13, 16);
+var
+ a : array of SizeInt;
+ i : LongInt;
+begin
+ if FindMatchesBoyerMooreCaseSensitive('abcabcabcabcabcabcab','abcab',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(2);
+ if a[0]<>result1[0] then
+ halt(3);
+ end
+ else
+ halt(1);
+
+ if FindMatchesBoyerMooreCaseSensitive('abcabcabcabcabcabcab','abcab',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(12);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(13);
+ end
+ else
+ halt(11);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcabcabcabcab','abcab',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(22);
+ if a[0]<>result1[0] then
+ halt(23);
+ end
+ else
+ halt(21);
+
+{
+ apparently not working yet:
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcabcabcabcab','abcab',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(32);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(33);
+ end
+ else
+ halt(31);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcAbcabcAbcab','abcaB',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(42);
+ if a[0]<>result1[0] then
+ halt(43);
+ end
+ else
+ halt(41);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabCabcAbcabcABcab','abcaB',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(52);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(53);
+ end
+ else
+ halt(51);
+}
+
+ writeln('ok');
+end.