Browse Source

+ added missing test

git-svn-id: trunk@3562 -
florian 19 years ago
parent
commit
ecf4a7faff
2 changed files with 55 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 54 0
      tests/webtbs/tw6491.pp

+ 1 - 0
.gitattributes

@@ -6817,6 +6817,7 @@ tests/webtbs/tw5015.pp svneol=native#text/plain
 tests/webtbs/tw5023.pp svneol=native#text/plain
 tests/webtbs/tw5023.pp svneol=native#text/plain
 tests/webtbs/tw5036.pp svneol=native#text/plain
 tests/webtbs/tw5036.pp svneol=native#text/plain
 tests/webtbs/tw5082.pp -text svneol=unset#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/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 54 - 0
tests/webtbs/tw6491.pp

@@ -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.
+