strex: added `detectUrl()`
[iv.d.git] / arcztest / ztest.d
blob60b9093d528a7df7cc0f447c6bff79b8593647b5
1 module ztest /*is aliced*/;
3 import std.stdio;
4 import std.random;
6 import iv.alice;
7 import iv.arcz;
10 // ////////////////////////////////////////////////////////////////////////// //
11 enum ArcName = "z00.arz";
12 //enum FileName = "arsd.cgi.Cgi.request.html";
13 //enum DirName = "experimental-docs";
14 enum FileName = "license.txt";
15 enum DirName = "00/dmd2";
18 // ////////////////////////////////////////////////////////////////////////// //
19 void main (string[] args) {
20 import std.stdio;
21 ArzArchive arc;
22 writeln("opening archive...");
23 arc.openArchive(args.length > 1 ? args[1] : ArcName);
24 writeln(arc.files.length, " files found");
25 ubyte[] ofile;
27 auto fl = File(DirName~"/"~FileName);
28 ofile = new ubyte[](cast(uint)fl.size);
29 fl.rawRead(ofile[]);
32 auto fl = arc.open(args.length > 2 ? args[2] : FileName);
33 writeln("size: ", fl.size);
34 long opos = -1;
35 foreach (immutable _; 0..1000000) {
36 ubyte[1] b;
37 uint npos = uniform!"[)"(0, fl.size);
38 opos = fl.tell;
39 fl.seek(npos);
40 b[] = 0;
41 auto r = fl.rawRead(b[]);
42 if (r.length != b.length) {
43 writeln("opos=", opos, "; npos=", npos);
44 assert(0, "wtf00?!");
46 if (b[0] != ofile[npos]) {
47 writeln("opos=", opos, "; npos=", npos, "; ofile[npos]=", ofile[npos], "; b[0]=", b[0]);
48 assert(0, "wtf01?!");