zymosis: cosmetix
[iv.d.git] / arcztest / ztest.d
blob2c0af79ec426bbe2155d15758c084eb6d30d78a0
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";
16 // ////////////////////////////////////////////////////////////////////////// //
17 void main (string[] args) {
18 import std.stdio;
19 ArzArchive arc;
20 writeln("opening archive...");
21 arc.openArchive(args.length > 1 ? args[1] : ArcName);
22 writeln(arc.files.length, " files found");
23 ubyte[] ofile;
25 auto fl = File(DirName~"/"~FileName);
26 ofile = new ubyte[](cast(uint)fl.size);
27 fl.rawRead(ofile[]);
30 auto fl = arc.open(args.length > 2 ? args[2] : FileName);
31 writeln("size: ", fl.size);
32 long opos = -1;
33 foreach (immutable _; 0..1000000) {
34 ubyte[1] b;
35 uint npos = uniform!"[)"(0, fl.size);
36 opos = fl.tell;
37 fl.seek(npos);
38 b[] = 0;
39 auto r = fl.rawRead(b[]);
40 if (r.length != b.length) {
41 writeln("opos=", opos, "; npos=", npos);
42 assert(0, "wtf00?!");
44 if (b[0] != ofile[npos]) {
45 writeln("opos=", opos, "; npos=", npos, "; ofile[npos]=", ofile[npos], "; b[0]=", b[0]);
46 assert(0, "wtf01?!");