mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 21:40:34 +02:00
+ added missing test
git-svn-id: trunk@3562 -
This commit is contained in:
parent
435374815d
commit
ecf4a7faff
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6817,6 +6817,7 @@ tests/webtbs/tw5015.pp svneol=native#text/plain
|
||||
tests/webtbs/tw5023.pp svneol=native#text/plain
|
||||
tests/webtbs/tw5036.pp svneol=native#text/plain
|
||||
tests/webtbs/tw5082.pp -text svneol=unset#text/plain
|
||||
tests/webtbs/tw6491.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||
|
54
tests/webtbs/tw6491.pp
Normal file
54
tests/webtbs/tw6491.pp
Normal file
@ -0,0 +1,54 @@
|
||||
program TestExtractDrive;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$mode objfpc}{$H+}
|
||||
{$ELSE}
|
||||
{$APPTYPE CONSOLE}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
|
||||
function tiRemoveDrive(pStrPath : string) : string;
|
||||
var
|
||||
sDrive : string;
|
||||
begin
|
||||
sDrive := extractFileDrive(pStrPath);
|
||||
if sDrive <> '' then begin
|
||||
result := copy(pStrPath, length(sDrive)+1, length(pStrPath) - length(sDrive));
|
||||
end else begin
|
||||
result := pStrPath;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure CheckEquals(expected, actual, msg: string);
|
||||
const
|
||||
c = '%s: Expected <%s> but found <%s>';
|
||||
begin
|
||||
if expected <> actual then
|
||||
begin
|
||||
Writeln(Format(c, [msg, expected, actual]));
|
||||
halt(1);
|
||||
end
|
||||
else
|
||||
Writeln('...test passed.');
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
Writeln('Start tests...');
|
||||
{ What I use in my application }
|
||||
CheckEquals('', tiRemoveDrive('c:'), 'Failed on 1');
|
||||
CheckEquals('\temp', tiRemoveDrive('c:\temp'), 'Failed on 2');
|
||||
CheckEquals('\temp\hos.txt', tiRemoveDrive('c:\temp\hos.txt'), 'Failed on 3');
|
||||
CheckEquals('\Program Files\My Program\run.bat', tiRemoveDrive('c:\Program Files\My Program\run.bat'), 'Failed on 4');
|
||||
{ To put the previous four test in a different way, calling ExtractFileDrive directly. }
|
||||
CheckEquals('c:', ExtractFileDrive('c:'), 'Failed on 5');
|
||||
CheckEquals('c:', ExtractFileDrive('c:\temp'), 'Failed on 6');
|
||||
CheckEquals('c:', ExtractFileDrive('c:\temp\hos.txt'), 'Failed on 6');
|
||||
CheckEquals('c:', ExtractFileDrive('c:\Program Files\My Program\run.bat'), 'Failed on 7');
|
||||
Writeln('Done.');
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user