tdos2.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. {******************************************}
  2. { Used to check the DOS unit }
  3. {------------------------------------------}
  4. { Requirements for this unit can be }
  5. { found in testdos.htm }
  6. {******************************************}
  7. Program TestDos;
  8. Uses Dos;
  9. {**********************************************************************}
  10. { Some specific OS verifications : }
  11. { Mainly for file attributes: }
  12. { Read-Only }
  13. { Hidden }
  14. { System File }
  15. { only work on Win32, OS/2 and DOS }
  16. {$IFDEF MSDOS}
  17. {$DEFINE EXTATTR}
  18. {$ENDIF}
  19. {$IFDEF DPMI}
  20. {$DEFINE EXTATTR}
  21. {$ENDIF}
  22. {$IFDEF GO32V1}
  23. {$DEFINE EXTATTR}
  24. {$ENDIF}
  25. {$IFDEF GO32V2}
  26. {$DEFINE EXTATTR}
  27. {$ENDIF}
  28. {$IFDEF OS2}
  29. {$DEFINE EXTATTR}
  30. {$ENDIF}
  31. {$IFDEF WIN32}
  32. {$DEFINE EXTATTR}
  33. {$ENDIF}
  34. {$IFDEF ATARI}
  35. {$DEFINE EXTATTR}
  36. {$ENDIF}
  37. {$IFNDEF UNIX}
  38. {$IFDEF LINUX}
  39. {$DEFINE UNIX}
  40. {$ENDIF}
  41. {$IFDEF QNX}
  42. {$DEFINE UNIX}
  43. {$ENDIF}
  44. {$IFDEF SOLARIS}
  45. {$DEFINE UNIX}
  46. {$ENDIF}
  47. {$IFDEF FREEBSD}
  48. {$DEFINE UNIX}
  49. {$ENDIF}
  50. {$IFDEF BEOS}
  51. {$DEFINE UNIX}
  52. {$ENDIF}
  53. {$ENDIF}
  54. {**********************************************************************}
  55. CONST
  56. { what is the root path }
  57. {$IFDEF EXTATTR}
  58. RootPath = 'C:\';
  59. {$ENDIF}
  60. {$IFDEF UNIX}
  61. RootPath = '/';
  62. {$ENDIF}
  63. Week:Array[0..6] of String =
  64. ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  65. TestFName = 'TESTDOS.DAT'; { CASE SENSITIVE DON'T TOUCH! }
  66. TestFName1 = 'TESTFILE'; { CASE SENSITIVE DON'T TOUCH! }
  67. TestDir = 'MYDIR'; { CASE SENSITIVE DON'T TOUCH! }
  68. TestExt = 'DAT';
  69. has_errors : boolean = false;
  70. Procedure PauseScreen;
  71. var
  72. ch: char;
  73. Begin
  74. { this is the non-interacting version
  75. so we disable this
  76. WriteLn('-- Press any key --');
  77. ReadLn;}
  78. end;
  79. { verifies that the DOSError variable is equal to }
  80. { the value requested. }
  81. Procedure CheckDosError(err: Integer);
  82. var
  83. x : integer;
  84. s :string;
  85. Begin
  86. Write('Verifying value of DOS Error...');
  87. x := DosError;
  88. case x of
  89. 0 : s := '(0): No Error.';
  90. 2 : s := '(2): File not found.';
  91. 3 : s := '(3): Path not found.';
  92. 5 : s := '(5): Access Denied.';
  93. 6 : s := '(6): Invalid File Handle.';
  94. 8 : s := '(8): Not enough memory.';
  95. 10 : s := '(10) : Invalid Environment.';
  96. 11 : s := '(11) : Invalid format.';
  97. 18 : s := '(18) : No more files.';
  98. else
  99. s := 'INVALID DOSERROR';
  100. end;
  101. if err <> x then
  102. Begin
  103. WriteLn('FAILURE. (Value should be ',err,' '+s+')');
  104. has_errors:=true;
  105. end
  106. else
  107. WriteLn('Success.');
  108. end;
  109. Procedure TestSystemDate;
  110. var
  111. Year,Month, DayOfWeek, Day: Word;
  112. Year1,Month1, DayOfWeek1, Day1: Word;
  113. s: string;
  114. Begin
  115. WriteLn('----------------------------------------------------------------------');
  116. WriteLn(' GETDATE ');
  117. WriteLn('----------------------------------------------------------------------');
  118. WriteLn(' Note: Number of week should be consistent (0 = Sunday) ');
  119. WriteLn(' Note: Year should contain full four digits. ');
  120. WriteLn('----------------------------------------------------------------------');
  121. CheckDosError(0);
  122. Month:=0;
  123. Day:=0;
  124. DayOfWeek:=0;
  125. Year:=0;
  126. GetDate(Year,Month,Day,DayOfWeek);
  127. CheckDosError(0);
  128. Write('DD-MM-YYYY : ',Day,'-',Month,'-',Year);
  129. WriteLn(' (',Week[DayOfWeek],')');
  130. PauseScreen;
  131. WriteLn('----------------------------------------------------------------------');
  132. WriteLn(' SETDATE ');
  133. WriteLn('----------------------------------------------------------------------');
  134. { normal call }
  135. SetDate(Year,Month,Day);
  136. CheckDosError(0);
  137. { setdate and settime is not supported on most platforms }
  138. {$ifdef go32v2}
  139. s:='Testing with invalid year....';
  140. SetDate(98,Month,Day);
  141. CheckDosError(0);
  142. GetDate(Year1,Month1,Day1,DayOfWeek1);
  143. CheckDosError(0);
  144. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  145. Begin
  146. WriteLn(s+'FAILURE.');
  147. end
  148. else
  149. WriteLn(s+'Success.');
  150. SetDate(Year,Month,255);
  151. CheckDosError(0);
  152. s:='Testing with invalid day.....';
  153. GetDate(Year1,Month1,Day1,DayOfWeek1);
  154. CheckDosError(0);
  155. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  156. Begin
  157. WriteLn(s+'FAILURE.');
  158. end
  159. else
  160. WriteLn(s+'Success.');
  161. SetDate(Year,13,Day);
  162. CheckDosError(0);
  163. s:='Testing with invalid month...';
  164. GetDate(Year1,Month1,Day1,DayOfWeek1);
  165. CheckDosError(0);
  166. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  167. Begin
  168. WriteLn(s+'FAILURE.');
  169. end
  170. else
  171. WriteLn(s+'Success.');
  172. WriteLn('----------------------------------------------------------------------');
  173. WriteLn(' Note: Date should be 01-01-1998 ');
  174. WriteLn('----------------------------------------------------------------------');
  175. SetDate(1998,01,01);
  176. CheckDosError(0);
  177. GetDate(Year1,Month1,Day1,DayOfWeek1);
  178. CheckDosError(0);
  179. WriteLn('DD-MM-YYYY : ',Day1,'-',Month1,'-',Year1);
  180. SetDate(Year,Month,Day);
  181. CheckDosError(0);
  182. WriteLn('----------------------------------------------------------------------');
  183. WriteLn(' Note: Date should be restored to previous value ');
  184. WriteLn('----------------------------------------------------------------------');
  185. GetDate(Year1,Month1,Day1,DayOfWeek1);
  186. CheckDosError(0);
  187. WriteLn('DD-MM-YYYY : ',Day1,'-',Month1,'-',Year1);
  188. PauseScreen;
  189. {$endif}
  190. end;
  191. Procedure TestsystemTime;
  192. Var
  193. Hour, Minute, Second, Sec100: word;
  194. Hour1, Minute1, Second1, Sec1001: word;
  195. Begin
  196. WriteLn('----------------------------------------------------------------------');
  197. WriteLn(' GETTIME ');
  198. WriteLn('----------------------------------------------------------------------');
  199. WriteLn(' Note: Hours should be in military format (0..23), and MSec in 0..100 ');
  200. WriteLn('----------------------------------------------------------------------');
  201. CheckDosError(0);
  202. Hour:=0;
  203. Minute:=0;
  204. Second:=0;
  205. Sec100:=0;
  206. GetTime(Hour,Minute,Second,Sec100);
  207. CheckDosError(0);
  208. WriteLn('HH:MIN:SEC (MS): ',Hour,':',Minute,':',Second,' (',Sec100,')');
  209. WriteLn('----------------------------------------------------------------------');
  210. WriteLn(' SETTIME ');
  211. WriteLn('----------------------------------------------------------------------');
  212. WriteLn(' Note: GetTime should return the same value as the previous test. ');
  213. WriteLn('----------------------------------------------------------------------');
  214. SetTime(36,Minute,Second,Sec100);
  215. CheckDosError(0);
  216. GetTime(Hour1,Minute1,Second1,Sec1001);
  217. CheckDosError(0);
  218. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  219. { actual settime is only supported under DOS }
  220. {$ifdef go32v2}
  221. SetTime(Hour,32000,Second,Sec100);
  222. CheckDosError(0);
  223. GetTime(Hour1,Minute1,Second1,Sec1001);
  224. CheckDosError(0);
  225. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  226. WriteLn('----------------------------------------------------------------------');
  227. WriteLn(' Note: GetTime should return 0:0:0 ');
  228. WriteLn('----------------------------------------------------------------------');
  229. SetTime(0,0,0,0);
  230. CheckDosError(0);
  231. GetTime(Hour1,Minute1,Second1,Sec1001);
  232. CheckDosError(0);
  233. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  234. WriteLn('----------------------------------------------------------------------');
  235. WriteLn(' Note: GetTime should return approximately the original time ');
  236. WriteLn('----------------------------------------------------------------------');
  237. SetTime(Hour,Minute,Second,Sec1001);
  238. CheckDosError(0);
  239. GetTime(Hour1,Minute1,Second1,Sec1001);
  240. CheckDosError(0);
  241. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  242. {$endif}
  243. end;
  244. Procedure TestFTime;
  245. var
  246. s : string;
  247. F: File;
  248. Time: Longint;
  249. DT: DateTime;
  250. DT1 : Datetime; { saved values }
  251. Begin
  252. WriteLn('----------------------------------------------------------------------');
  253. WriteLn(' GETFTIME / SETFTIME ');
  254. WriteLn('----------------------------------------------------------------------');
  255. CheckDosError(0);
  256. {**********************************************************************}
  257. {********************** TURBO PASCAL BUG ******************************}
  258. { The File is not Open and DosError is still zero! THIS SHOULD NOT BE }
  259. { SO IN FPC! }
  260. {**********************************************************************}
  261. {********************** TURBO PASCAL BUG ******************************}
  262. Write('Assigning an invalid file...');
  263. Assign(f,'x');
  264. GetFTime(f,Time);
  265. {$ifndef macos}
  266. CheckDosError(6);
  267. {$else}
  268. CheckDosError(2); {Since on MacOS, GetFTime works even for non-opened files}
  269. {$endif}
  270. Write('Trying to open ',TestFName,'...');
  271. Assign(f,TestFName);
  272. Reset(f,1);
  273. GetFTime(f,Time);
  274. CheckDosError(0);
  275. UnpackTime(Time,Dt);
  276. WriteLn('----------------------------------------------------------------------');
  277. WriteLn(' Note: Hour should be in military format and year should be a 4 digit ');
  278. WriteLn(' number. ');
  279. WriteLn('----------------------------------------------------------------------');
  280. WriteLn('DD-MM-YYYY : ',DT.Day,'-',DT.Month,'-',DT.Year);
  281. WriteLn('HH:MIN:SEC ',DT.Hour,':',DT.Min,':',DT.Sec);
  282. { SETFTIME / GETFTIME No Range checking is performed so the tests are }
  283. { very limited. }
  284. s:='Setting '+TestFName+' date/time to 01-28-1998:0:0:0...';
  285. dt1.Year:=1998;
  286. dt1.Month:=1;
  287. dt1.Day:=28;
  288. Dt1.Hour:=0;
  289. Dt1.Min:=0;
  290. Dt1.Sec:=0;
  291. PackTime(DT1,Time);
  292. CheckDosError(0);
  293. SetFTime(f,Time);
  294. CheckDosError(0);
  295. GetFTime(f,Time);
  296. CheckDosError(0);
  297. { Re-initialize the date time file }
  298. FillChar(Dt1,sizeof(dt1),#0);
  299. UnpackTime(Time,Dt1);
  300. if (Dt1.Year <> 1998) or (Dt1.Month<>1) or (Dt1.Day<>28) or
  301. (Dt1.Hour<>0) or (Dt1.Min <>0) or (Dt1.Sec<>0) then
  302. Begin
  303. WriteLn(s+'FAILURE.');
  304. end
  305. else
  306. WriteLn(s+'Success.');
  307. s:='Restoring old file time stamp...';
  308. Move(Dt,Dt1,sizeof(Dt));
  309. PackTime(DT1,Time);
  310. CheckDosError(0);
  311. SetFTime(f,Time);
  312. CheckDosError(0);
  313. GetFTime(f,Time);
  314. CheckDosError(0);
  315. { Re-initialize the date time file }
  316. FillChar(Dt1,sizeof(dt),#0);
  317. UnpackTime(Time,Dt1);
  318. if (Dt1.Year <> Dt.Year) or (Dt1.Month<>Dt.Month) or (Dt1.Day<>Dt.Day) or
  319. (Dt1.Hour<>Dt.Hour) or (Dt1.Min <> Dt.Min) or (Dt1.Sec<>Dt.Sec) then
  320. Begin
  321. WriteLn(s+'FAILURE.');
  322. end
  323. else
  324. WriteLn(s+'Success.');
  325. Close(f);
  326. end;
  327. Procedure TestFind;
  328. var
  329. Search: SearchRec;
  330. DT: Datetime;
  331. Year, Month, Day, DayOfWeek: Word;
  332. Failure : Boolean;
  333. FoundDot, FoundDotDot: boolean;
  334. FoundDir : boolean;
  335. s : string;
  336. Begin
  337. WriteLn('----------------------------------------------------------------------');
  338. WriteLn(' FINDFIRST/ FINDNEXT ');
  339. WriteLn('----------------------------------------------------------------------');
  340. WriteLn(' Note: The full path should NOT be displayed. ');
  341. WriteLn('----------------------------------------------------------------------');
  342. CheckDosError(0);
  343. WriteLn('Trying to find an invalid file ('''') with Any Attribute...');
  344. FindFirst('',AnyFile,Search);
  345. CheckDosError(3);
  346. {$IFDEF FPC}
  347. FindClose(Search);
  348. {$ENDIF}
  349. {$ifdef go32v2}
  350. WriteLn('Trying to find an invalid file ('''') with VolumeID attribute...');
  351. FindFirst('',VolumeID,Search);
  352. CheckDosError(3);
  353. {$IFDEF FPC}
  354. FindClose(Search);
  355. {$ENDIF}
  356. {$endif go32v2}
  357. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Any Attribute...');
  358. FindFirst('zz.dat',AnyFile,Search);
  359. CheckDosError(18);
  360. {$IFDEF FPC}
  361. FindClose(Search);
  362. {$ENDIF}
  363. WriteLn('Trying to find an invalid file (''''zz.dat'''') with VolumeID attribute...');
  364. FindFirst('zz.dat',VolumeID,Search);
  365. CheckDosError(18);
  366. {$IFDEF FPC}
  367. FindClose(Search);
  368. {$ENDIF}
  369. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Directory attribute...');
  370. FindFirst('zz.dat',Directory,Search);
  371. CheckDosError(18);
  372. {$IFDEF FPC}
  373. FindClose(Search);
  374. {$ENDIF}
  375. s:='Looking for '+TestFName +' with Any Attribute...';
  376. FindFirst('*.DAT',AnyFile,Search);
  377. if Search.Name <> TestFName then
  378. Begin
  379. repeat
  380. FindNext(Search);
  381. until (DosError <> 0) OR (Search.Name = TestFName);
  382. end;
  383. if Search.Name <> TestFName then
  384. { At least testdos.dat should appear }
  385. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  386. else
  387. WriteLn(s+'Success.');
  388. {$IFDEF FPC}
  389. FindClose(Search);
  390. {$ENDIF}
  391. { In addition to normal files }
  392. { directory files should also be found }
  393. s:='Looking for '+TestFName +' with Directory Attribute...';
  394. FindFirst('*.DAT',Archive+Directory,Search);
  395. if DosError<> 0 then
  396. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  397. else
  398. WriteLn(s+'Success.');
  399. if Search.Name <> TestFName then
  400. Begin
  401. repeat
  402. FindNext(Search);
  403. until (DosError <> 0) OR (Search.Name = TestFName);
  404. end;
  405. {$IFDEF FPC}
  406. FindClose(Search);
  407. {$ENDIF}
  408. Write('Checking file stats of ',TestFName,'...');
  409. UnpackTime(Search.Time,DT);
  410. GetDate(Year, Month, Day, DayOfWeek);
  411. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  412. OR (DT.Day <> Day)
  413. then
  414. Begin
  415. WriteLn('FAILURE. Size/Date is different.')
  416. end
  417. else
  418. WriteLn('Success.');
  419. Write('Looking for ',TestFName,'...');
  420. FindFirst('*.D??',AnyFile,Search);
  421. { At least testdos.dat should appear }
  422. if DosError <> 0 then
  423. WriteLn('FAILURE. ',Testfname,' should be found.')
  424. else
  425. WriteLn('Success.');
  426. if Search.Name <> TestFName then
  427. Begin
  428. repeat
  429. FindNext(Search);
  430. until (DosError <> 0) OR (Search.Name = TestFName);
  431. end;
  432. {$IFDEF FPC}
  433. FindClose(Search);
  434. {$ENDIF}
  435. Write('Checking file stats of ',TestFName,'...');
  436. UnpackTime(Search.Time,DT);
  437. GetDate(Year, Month, Day, DayOfWeek);
  438. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  439. OR (DT.Day <> Day)
  440. then
  441. Begin
  442. WriteLn('FAILURE. Size/Date is different.')
  443. end
  444. else
  445. WriteLn('Success.');
  446. { Should show all possible files }
  447. FoundDot := False;
  448. FoundDotDot := False;
  449. Failure := True;
  450. FoundDir := False;
  451. s:='Searching using * wildcard (normal files + directories)...';
  452. FindFirst('*',Archive+Directory,Search);
  453. WriteLn(#9'Resources found (full path should not be displayed):');
  454. while DosError = 0 do
  455. Begin
  456. If Search.Name = TestDir then
  457. Begin
  458. If Search.Attr and Directory <> 0 then
  459. FoundDir := TRUE;
  460. end;
  461. If Search.Name = '.' then
  462. Begin
  463. If Search.Attr and Directory <> 0 then
  464. FoundDot := TRUE;
  465. End;
  466. if Search.Name = '..' then
  467. Begin
  468. If Search.Attr and Directory <> 0 then
  469. FoundDotDot := TRUE;
  470. End;
  471. { check for both . and .. special files }
  472. If Search.Name = TestFName1 then
  473. Failure := FALSE;
  474. WriteLn(#9+Search.Name);
  475. FindNext(Search);
  476. end;
  477. {$IFDEF FPC}
  478. FindClose(Search);
  479. {$ENDIF}
  480. if not FoundDir then
  481. WriteLn(s+'FAILURE. Did not find '+TestDir+' directory')
  482. else
  483. if not FoundDot then
  484. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  485. else
  486. if not FoundDotDot then
  487. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  488. else
  489. if Failure then
  490. WriteLn(s+'FAILURE. Did not find special '+TestFName1+' directory')
  491. else
  492. WriteLn(s+'Success.');
  493. {$IFDEF FPC}
  494. FindClose(Search);
  495. {$ENDIF}
  496. {$ifdef go32v2}
  497. s:='Searching using ??? wildcard (normal files + all special files)...';
  498. FindFirst('???',AnyFile,Search);
  499. FoundDot := False;
  500. FoundDotDot := False;
  501. WriteLn(#9'Resources found (full path should not be displayed):');
  502. while DosError = 0 do
  503. Begin
  504. If Search.Name = '.' then
  505. Begin
  506. If Search.Attr and Directory <> 0 then
  507. FoundDot := TRUE;
  508. End;
  509. if Search.Name = '..' then
  510. Begin
  511. If Search.Attr and Directory <> 0 then
  512. FoundDotDot := TRUE;
  513. End;
  514. WriteLn(#9+Search.Name);
  515. FindNext(Search);
  516. end;
  517. if not FoundDot then
  518. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  519. else
  520. if not FoundDotDot then
  521. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  522. else
  523. WriteLn(s+'Success.');
  524. {$IFDEF FPC}
  525. FindClose(Search);
  526. {$ENDIF}
  527. { search for volume ID }
  528. s:='Searching using * wildcard in ROOT (normal files + volume ID)...';
  529. FindFirst(RootPath+'*',Directory+VolumeID,Search);
  530. Failure := TRUE;
  531. WriteLn(#9'Resources found (full path should not be displayed):');
  532. while DosError = 0 do
  533. Begin
  534. If Search.Attr and VolumeID <> 0 then
  535. Begin
  536. Failure := FALSE;
  537. WriteLn(#9'Volume ID: '+Search.Name);
  538. End
  539. else
  540. WriteLn(#9+Search.Name);
  541. FindNext(Search);
  542. end;
  543. If Failure then
  544. WriteLn(s+'FAILURE. Did not find volume name')
  545. else
  546. WriteLn(s+'Success.');
  547. {$IFDEF FPC}
  548. FindClose(Search);
  549. {$ENDIF}
  550. {$endif}
  551. end;
  552. Procedure TestSplit;
  553. var
  554. P: PathStr;
  555. D: DirStr;
  556. N: NameStr;
  557. E: ExtStr;
  558. temp : string;
  559. Begin
  560. WriteLn('----------------------------------------------------------------------');
  561. WriteLn(' FSPLIT ');
  562. WriteLn('----------------------------------------------------------------------');
  563. Write('Testing invalid filename...');
  564. { Initialize names ot invalid values! }
  565. D:='Garbage';
  566. N:='Garbage';
  567. E:='GAR';
  568. { This is the path to be split }
  569. P:='';
  570. FSPlit(P,D,N,E);
  571. IF (length(D) <> 0) OR (length(N) <>0) OR (length(E) <> 0) THEN
  572. WriteLn('FAILURE. Same length as PATH (now length 0) should be returned.')
  573. else
  574. WriteLn('Success.');
  575. Write('Testing paramstr(0)...');
  576. { Initialize names ot invalid values! }
  577. D:='Garbage';
  578. N:='Garbage';
  579. E:='GAR';
  580. { This is the path to be split }
  581. P:=paramstr(0);
  582. FSPlit(P,D,N,E);
  583. IF length(p) <> (length(d)+length(n)+length(e)) then
  584. WriteLn('FAILURE. Same length as PATH should be returned.')
  585. else
  586. WriteLn('Success.');
  587. temp:=d+n+e;
  588. Write('Testing paramstr(0)...');
  589. if temp <> p then
  590. WriteLn('FAILURE. Concatenated string should be the same.')
  591. else
  592. WriteLn('Success.');
  593. WriteLn('PARAMSTR(0) = ', ParamStr(0));
  594. WriteLn('DRIVE + NAME + EXT = ',d+n+e);
  595. {$ifdef go32v2}
  596. Write('Testing invalid path (..)...');
  597. P:='..';
  598. FSPlit(P,D,N,E);
  599. IF (length(D) <> 0) OR (length(N) <>0) OR (E <> P) THEN
  600. WriteLn('FAILURE. Length of drive and name should be zero and Ext should return Path')
  601. else
  602. WriteLn('Success.');
  603. {$endif}
  604. Write('Testing invalid path (*)...');
  605. P:='*';
  606. FSPlit(P,D,N,E);
  607. IF (length(D) <> 0) OR (length(e) <>0) OR (N <> P) THEN
  608. WriteLn('FAILURE. Length of drive and name should be zero and Name should return Path')
  609. else
  610. WriteLn('Success.');
  611. end;
  612. var
  613. F: File;
  614. Attr : Word;
  615. Begin
  616. {$IFDEF MACOS}
  617. pathTranslation:= true;
  618. {$ENDIF}
  619. TestSystemDate;
  620. TestSystemTime;
  621. { Now the file I/O functions }
  622. { Let us create a file that we will play with }
  623. Assign(f,TestFName);
  624. Rewrite(f,1);
  625. BlockWrite(f,Week,sizeof(Week));
  626. Close(f);
  627. Assign(f,TestFName1);
  628. Rewrite(f,1);
  629. Close(F);
  630. MkDir(TestDir);
  631. TestFTime;
  632. TestFind;
  633. PauseScreen;
  634. TestSplit;
  635. RmDir(TestDir);
  636. PauseScreen;
  637. { Cleanup }
  638. {$I-}
  639. assign(f,TestFName);
  640. erase(f);
  641. assign(f,TestFName1);
  642. erase(f);
  643. {$I+}
  644. if ioresult<>0 then;
  645. if has_errors then
  646. halt(1);
  647. end.