tdos2.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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('Opening an invalid file...');
  263. Assign(f,'x');
  264. GetFTime(f,Time);
  265. CheckDosError(6);
  266. Write('Trying to open ',TestFName,'...');
  267. Assign(f,TestFName);
  268. Reset(f,1);
  269. GetFTime(f,Time);
  270. CheckDosError(0);
  271. UnpackTime(Time,Dt);
  272. WriteLn('----------------------------------------------------------------------');
  273. WriteLn(' Note: Hour should be in military format and year should be a 4 digit ');
  274. WriteLn(' number. ');
  275. WriteLn('----------------------------------------------------------------------');
  276. WriteLn('DD-MM-YYYY : ',DT.Day,'-',DT.Month,'-',DT.Year);
  277. WriteLn('HH:MIN:SEC ',DT.Hour,':',DT.Min,':',DT.Sec);
  278. { SETFTIME / GETFTIME No Range checking is performed so the tests are }
  279. { very limited. }
  280. s:='Setting '+TestFName+' date/time to 01-28-1998:0:0:0...';
  281. dt1.Year:=1998;
  282. dt1.Month:=1;
  283. dt1.Day:=28;
  284. Dt1.Hour:=0;
  285. Dt1.Min:=0;
  286. Dt1.Sec:=0;
  287. PackTime(DT1,Time);
  288. CheckDosError(0);
  289. SetFTime(f,Time);
  290. CheckDosError(0);
  291. GetFTime(f,Time);
  292. CheckDosError(0);
  293. { Re-initialize the date time file }
  294. FillChar(Dt1,sizeof(dt1),#0);
  295. UnpackTime(Time,Dt1);
  296. if (Dt1.Year <> 1998) or (Dt1.Month<>1) or (Dt1.Day<>28) or
  297. (Dt1.Hour<>0) or (Dt1.Min <>0) or (Dt1.Sec<>0) then
  298. Begin
  299. WriteLn(s+'FAILURE.');
  300. end
  301. else
  302. WriteLn(s+'Success.');
  303. s:='Restoring old file time stamp...';
  304. Move(Dt,Dt1,sizeof(Dt));
  305. PackTime(DT1,Time);
  306. CheckDosError(0);
  307. SetFTime(f,Time);
  308. CheckDosError(0);
  309. GetFTime(f,Time);
  310. CheckDosError(0);
  311. { Re-initialize the date time file }
  312. FillChar(Dt1,sizeof(dt),#0);
  313. UnpackTime(Time,Dt1);
  314. if (Dt1.Year <> Dt.Year) or (Dt1.Month<>Dt.Month) or (Dt1.Day<>Dt.Day) or
  315. (Dt1.Hour<>Dt.Hour) or (Dt1.Min <> Dt.Min) or (Dt1.Sec<>Dt.Sec) then
  316. Begin
  317. WriteLn(s+'FAILURE.');
  318. end
  319. else
  320. WriteLn(s+'Success.');
  321. Close(f);
  322. end;
  323. Procedure TestFind;
  324. var
  325. Search: SearchRec;
  326. DT: Datetime;
  327. Year, Month, Day, DayOfWeek: Word;
  328. Failure : Boolean;
  329. FoundDot, FoundDotDot: boolean;
  330. FoundDir : boolean;
  331. s : string;
  332. Begin
  333. WriteLn('----------------------------------------------------------------------');
  334. WriteLn(' FINDFIRST/ FINDNEXT ');
  335. WriteLn('----------------------------------------------------------------------');
  336. WriteLn(' Note: The full path should NOT be displayed. ');
  337. WriteLn('----------------------------------------------------------------------');
  338. CheckDosError(0);
  339. WriteLn('Trying to find an invalid file ('''') with Any Attribute...');
  340. FindFirst('',AnyFile,Search);
  341. CheckDosError(3);
  342. {$IFDEF FPC}
  343. FindClose(Search);
  344. {$ENDIF}
  345. {$ifdef go32v2}
  346. WriteLn('Trying to find an invalid file ('''') with VolumeID attribute...');
  347. FindFirst('',VolumeID,Search);
  348. CheckDosError(3);
  349. {$IFDEF FPC}
  350. FindClose(Search);
  351. {$ENDIF}
  352. {$endif go32v2}
  353. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Any Attribute...');
  354. FindFirst('zz.dat',AnyFile,Search);
  355. CheckDosError(18);
  356. {$IFDEF FPC}
  357. FindClose(Search);
  358. {$ENDIF}
  359. WriteLn('Trying to find an invalid file (''''zz.dat'''') with VolumeID attribute...');
  360. FindFirst('zz.dat',VolumeID,Search);
  361. CheckDosError(18);
  362. {$IFDEF FPC}
  363. FindClose(Search);
  364. {$ENDIF}
  365. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Directory attribute...');
  366. FindFirst('zz.dat',Directory,Search);
  367. CheckDosError(18);
  368. {$IFDEF FPC}
  369. FindClose(Search);
  370. {$ENDIF}
  371. s:='Looking for '+TestFName +' with Any Attribute...';
  372. FindFirst('*.DAT',AnyFile,Search);
  373. if Search.Name <> TestFName then
  374. Begin
  375. repeat
  376. FindNext(Search);
  377. until (DosError <> 0) OR (Search.Name = TestFName);
  378. end;
  379. if Search.Name <> TestFName then
  380. { At least testdos.dat should appear }
  381. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  382. else
  383. WriteLn(s+'Success.');
  384. {$IFDEF FPC}
  385. FindClose(Search);
  386. {$ENDIF}
  387. { In addition to normal files }
  388. { directory files should also be found }
  389. s:='Looking for '+TestFName +' with Directory Attribute...';
  390. FindFirst('*.DAT',Archive+Directory,Search);
  391. if DosError<> 0 then
  392. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  393. else
  394. WriteLn(s+'Success.');
  395. if Search.Name <> TestFName then
  396. Begin
  397. repeat
  398. FindNext(Search);
  399. until (DosError <> 0) OR (Search.Name = TestFName);
  400. end;
  401. {$IFDEF FPC}
  402. FindClose(Search);
  403. {$ENDIF}
  404. Write('Checking file stats of ',TestFName,'...');
  405. UnpackTime(Search.Time,DT);
  406. GetDate(Year, Month, Day, DayOfWeek);
  407. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  408. OR (DT.Day <> Day)
  409. then
  410. Begin
  411. WriteLn('FAILURE. Size/Date is different.')
  412. end
  413. else
  414. WriteLn('Success.');
  415. Write('Looking for ',TestFName,'...');
  416. FindFirst('*.D??',AnyFile,Search);
  417. { At least testdos.dat should appear }
  418. if DosError <> 0 then
  419. WriteLn('FAILURE. ',Testfname,' should be found.')
  420. else
  421. WriteLn('Success.');
  422. if Search.Name <> TestFName then
  423. Begin
  424. repeat
  425. FindNext(Search);
  426. until (DosError <> 0) OR (Search.Name = TestFName);
  427. end;
  428. {$IFDEF FPC}
  429. FindClose(Search);
  430. {$ENDIF}
  431. Write('Checking file stats of ',TestFName,'...');
  432. UnpackTime(Search.Time,DT);
  433. GetDate(Year, Month, Day, DayOfWeek);
  434. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  435. OR (DT.Day <> Day)
  436. then
  437. Begin
  438. WriteLn('FAILURE. Size/Date is different.')
  439. end
  440. else
  441. WriteLn('Success.');
  442. { Should show all possible files }
  443. FoundDot := False;
  444. FoundDotDot := False;
  445. Failure := True;
  446. FoundDir := False;
  447. s:='Searching using * wildcard (normal files + directories)...';
  448. FindFirst('*',Archive+Directory,Search);
  449. WriteLn(#9'Resources found (full path should not be displayed):');
  450. while DosError = 0 do
  451. Begin
  452. If Search.Name = TestDir then
  453. Begin
  454. If Search.Attr and Directory <> 0 then
  455. FoundDir := TRUE;
  456. end;
  457. If Search.Name = '.' then
  458. Begin
  459. If Search.Attr and Directory <> 0 then
  460. FoundDot := TRUE;
  461. End;
  462. if Search.Name = '..' then
  463. Begin
  464. If Search.Attr and Directory <> 0 then
  465. FoundDotDot := TRUE;
  466. End;
  467. { check for both . and .. special files }
  468. If Search.Name = TestFName1 then
  469. Failure := FALSE;
  470. WriteLn(#9+Search.Name);
  471. FindNext(Search);
  472. end;
  473. {$IFDEF FPC}
  474. FindClose(Search);
  475. {$ENDIF}
  476. if not FoundDir then
  477. WriteLn(s+'FAILURE. Did not find '+TestDir+' directory')
  478. else
  479. if not FoundDot then
  480. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  481. else
  482. if not FoundDotDot then
  483. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  484. else
  485. if Failure then
  486. WriteLn(s+'FAILURE. Did not find special '+TestFName1+' directory')
  487. else
  488. WriteLn(s+'Success.');
  489. {$IFDEF FPC}
  490. FindClose(Search);
  491. {$ENDIF}
  492. {$ifdef go32v2}
  493. s:='Searching using ??? wildcard (normal files + all special files)...';
  494. FindFirst('???',AnyFile,Search);
  495. FoundDot := False;
  496. FoundDotDot := False;
  497. WriteLn(#9'Resources found (full path should not be displayed):');
  498. while DosError = 0 do
  499. Begin
  500. If Search.Name = '.' then
  501. Begin
  502. If Search.Attr and Directory <> 0 then
  503. FoundDot := TRUE;
  504. End;
  505. if Search.Name = '..' then
  506. Begin
  507. If Search.Attr and Directory <> 0 then
  508. FoundDotDot := TRUE;
  509. End;
  510. WriteLn(#9+Search.Name);
  511. FindNext(Search);
  512. end;
  513. if not FoundDot then
  514. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  515. else
  516. if not FoundDotDot then
  517. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  518. else
  519. WriteLn(s+'Success.');
  520. {$IFDEF FPC}
  521. FindClose(Search);
  522. {$ENDIF}
  523. { search for volume ID }
  524. s:='Searching using * wildcard in ROOT (normal files + volume ID)...';
  525. FindFirst(RootPath+'*',Directory+VolumeID,Search);
  526. Failure := TRUE;
  527. WriteLn(#9'Resources found (full path should not be displayed):');
  528. while DosError = 0 do
  529. Begin
  530. If Search.Attr and VolumeID <> 0 then
  531. Begin
  532. Failure := FALSE;
  533. WriteLn(#9'Volume ID: '+Search.Name);
  534. End
  535. else
  536. WriteLn(#9+Search.Name);
  537. FindNext(Search);
  538. end;
  539. If Failure then
  540. WriteLn(s+'FAILURE. Did not find volume name')
  541. else
  542. WriteLn(s+'Success.');
  543. {$IFDEF FPC}
  544. FindClose(Search);
  545. {$ENDIF}
  546. {$endif}
  547. end;
  548. Procedure TestSplit;
  549. var
  550. P: PathStr;
  551. D: DirStr;
  552. N: NameStr;
  553. E: ExtStr;
  554. temp : string;
  555. Begin
  556. WriteLn('----------------------------------------------------------------------');
  557. WriteLn(' FSPLIT ');
  558. WriteLn('----------------------------------------------------------------------');
  559. Write('Testing invalid filename...');
  560. { Initialize names ot invalid values! }
  561. D:='Garbage';
  562. N:='Garbage';
  563. E:='GAR';
  564. { This is the path to be split }
  565. P:='';
  566. FSPlit(P,D,N,E);
  567. IF (length(D) <> 0) OR (length(N) <>0) OR (length(E) <> 0) THEN
  568. WriteLn('FAILURE. Same length as PATH (now length 0) should be returned.')
  569. else
  570. WriteLn('Success.');
  571. Write('Testing paramstr(0)...');
  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:=paramstr(0);
  578. FSPlit(P,D,N,E);
  579. IF length(p) <> (length(d)+length(n)+length(e)) then
  580. WriteLn('FAILURE. Same length as PATH should be returned.')
  581. else
  582. WriteLn('Success.');
  583. temp:=d+n+e;
  584. Write('Testing paramstr(0)...');
  585. if temp <> p then
  586. WriteLn('FAILURE. Concatenated string should be the same.')
  587. else
  588. WriteLn('Success.');
  589. WriteLn('PARAMSTR(0) = ', ParamStr(0));
  590. WriteLn('DRIVE + NAME + EXT = ',d+n+e);
  591. {$ifdef go32v2}
  592. Write('Testing invalid path (..)...');
  593. P:='..';
  594. FSPlit(P,D,N,E);
  595. IF (length(D) <> 0) OR (length(N) <>0) OR (E <> P) THEN
  596. WriteLn('FAILURE. Length of drive and name should be zero and Ext should return Path')
  597. else
  598. WriteLn('Success.');
  599. {$endif}
  600. Write('Testing invalid path (*)...');
  601. P:='*';
  602. FSPlit(P,D,N,E);
  603. IF (length(D) <> 0) OR (length(e) <>0) OR (N <> P) THEN
  604. WriteLn('FAILURE. Length of drive and name should be zero and Name should return Path')
  605. else
  606. WriteLn('Success.');
  607. end;
  608. var
  609. F: File;
  610. Attr : Word;
  611. Begin
  612. TestSystemDate;
  613. TestSystemTime;
  614. { Now the file I/O functions }
  615. { Let us create a file that we will play with }
  616. Assign(f,TestFName);
  617. Rewrite(f,1);
  618. BlockWrite(f,Week,sizeof(Week));
  619. Close(f);
  620. Assign(f,TestFName1);
  621. Rewrite(f,1);
  622. Close(F);
  623. MkDir(TestDir);
  624. TestFTime;
  625. TestFind;
  626. PauseScreen;
  627. TestSplit;
  628. RmDir(TestDir);
  629. PauseScreen;
  630. { Cleanup }
  631. {$I-}
  632. assign(f,TestFName);
  633. erase(f);
  634. assign(f,TestFName1);
  635. erase(f);
  636. {$I+}
  637. if ioresult<>0 then;
  638. if has_errors then
  639. halt(1);
  640. end.
  641. {
  642. $Log$
  643. Revision 1.12 2002-12-06 16:38:15 peter
  644. * cleanup tempfiles
  645. Revision 1.11 2002/12/06 16:36:17 peter
  646. * made more tests go32v2 specific because they expect (buggy?) Dos
  647. findfirst behaviour
  648. Revision 1.10 2002/11/27 16:41:46 peter
  649. * volumeid is dos specific
  650. Revision 1.9 2002/11/18 09:49:49 pierre
  651. * tried to make as many as possible tests non interactive
  652. Revision 1.8 2002/11/08 21:01:18 carl
  653. * separated some tests
  654. * make tfexpand more portable
  655. Revision 1.7 2002/09/07 15:40:56 peter
  656. * old logs removed and tabs fixed
  657. }