mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 04:06:08 +02:00
+ test for strcopy()
This commit is contained in:
parent
c4427e2b82
commit
238a764a6e
52
tests/test/units/strings/tstrcopy.pp
Normal file
52
tests/test/units/strings/tstrcopy.pp
Normal file
@ -0,0 +1,52 @@
|
||||
uses strings;
|
||||
|
||||
procedure test_strcopy;
|
||||
var
|
||||
p: pchar;
|
||||
s: array[0..256] of char;
|
||||
buf: array[0..512] of char;
|
||||
i, j, k, l: longint;
|
||||
begin
|
||||
for i := 0 to 256 do
|
||||
begin
|
||||
fillchar(s,sizeof(s),'b');
|
||||
s[i] := #0;
|
||||
for j := 0 to 3 do
|
||||
begin
|
||||
fillchar(buf,sizeof(buf),'a');
|
||||
p := strcopy(@buf[j+32],@s[0]);
|
||||
if (p <> @buf[j+32]) then
|
||||
begin
|
||||
writeln('error 0');
|
||||
halt(1);
|
||||
end;
|
||||
for l := 0 to j+31 do
|
||||
if buf[l] <> 'a' then
|
||||
begin
|
||||
writeln('error 1');
|
||||
halt(1);
|
||||
end;
|
||||
for l := j+32 to j+32+i-1 do
|
||||
if buf[l] <> 'b' then
|
||||
begin
|
||||
writeln('error 2');
|
||||
halt(1);
|
||||
end;
|
||||
if buf[j+i+32] <> #0 then
|
||||
begin
|
||||
writeln('error 3');
|
||||
halt(1);
|
||||
end;
|
||||
for l := j+i+32+1 to 512 do
|
||||
if buf[l] <> 'a' then
|
||||
begin
|
||||
writeln('error 4');
|
||||
halt(1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
test_strcopy;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user