tidos2.pp 19 KB

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