tdos2.pp 19 KB

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